Coding Plus Emu Features / Commands

Status
Not open for further replies.

JynX

Posting Freak
Feb 6, 2016
710
438
Mine didn't seem to like the 'SendPacket' part :(



Works like a charm, many thanks for sharing!



I was going to use your version as it tells them they received x from x, but..

Severity Code Description Project File Line Suppression State Error CS1061 'RoomUserManager' does not contain a definition for 'GetRoomUserByUsername' and no extension method 'GetRoomUserByUsername' accepting a first argument of type 'RoomUserManager' could be found (are you missing a using directive or an assembly reference?).

Code:
        public RoomUser GetRoomUserByUsername(string Username)
        {
            return this._users.Values.Where(x => x?.GetClient()?.GetHabbo() != null && x.GetClient().GetHabbo().Username == Username).FirstOrDefault();
        }
add that to your RoomUserManager
 
Jan 7, 2016
194
15
Users Online Command converted for R2:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.Database.Interfaces;
using System.Data;
using Plus.HabboHotel.Users;
using Plus.HabboHotel.GameClients;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator.Fun
{
    class UsersOnlineCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_usersonline"; }
        }
        public string Parameters
        {
            get { return ""; }
        }
        public string Description
        {
            get { return "Displays the current users online"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            string Output = "Current Users Online:\r";
            Output += "-----------------------\r";

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT username FROM users WHERE online = '1'");
                dbClient.RunQuery();

                DataTable Table = dbClient.GetTable();

                if (Table != null)
                {
                    foreach (DataRow Row in Table.Rows)
                    {
                        Output += Row["Username"].ToString() + "\r";
                    }
                }
                else
                {
                    Output += "There must be hidden users online!";
                }
            }
            Session.SendNotification(Output);
        }
    }
}
 

HolaBox

New Member
Feb 20, 2017
27
2
Room.SendPacket("Ass") is a way for R2 to get the message sent when a command is ran, so if it does that change SendPacket to .SendMessage if you are using R1. I've converted a few commands from R1 to R2 due to the fact R2 uses packets for messages in commands.
 
@HolaBox Let me know which version of the emulator you are using and I'll re-code it to work for your version.

I'm using the first version (i think) by Sledmore (habboon edit) from 06-01-16
 
Jan 7, 2016
194
15
Ya you are best using the SendNotification one then with the fix I provided unless it does not use dbClient to call the query.
 
Jan 7, 2016
194
15
It is but not for R2, it does not work for R2 lol. I actually tested it myself and it did not like the "Adapter" instead, it wanted dbClient.
 

JynX

Posting Freak
Feb 6, 2016
710
438
It is but not for R2, it does not work for R2 lol. I actually tested it myself and it did not like the "Adapter" instead, it wanted dbClient.
The variable you assign it to wouldn't matter at all. IQueryAdapter queryAdapter would work the same. IQueryAdapter is the variables type just like string name or int age. It wouldn't matter what you name it you could name it devbestIsAmazing and it would still function so clearly you fucked up somewhere.. Even other places in R2 and even R3 use dbClient so explain to me how it didn't work?
 
Jan 7, 2016
194
15
The variable you assign it to wouldn't matter at all. IQueryAdapter queryAdapter would work the same. IQueryAdapter is the variables type just like string name or int age. It wouldn't matter what you name it you could name it devbestIsAmazing and it would still function so clearly you fucked up somewhere.. Even other places in R2 and even R3 use dbClient so explain to me how it didn't work?
Here's your answer of why it didn't work with R2 that way he had Adapter.SetQuery:
And let's keep this thread clean due to it being to "help" people, not gripe.
 

JynX

Posting Freak
Feb 6, 2016
710
438
Here's your answer of why it didn't work with R2 that way he had Adapter.Query:
And let's keep this thread clean due to it being to "help" people, not gripe.
That's an interface what does that have to do with anything? That just says that if we have something like:
Code:
namespace You.Are.A.Retard
{
    class YouHaveAutism : IQueryAdapter
    {
    
    }
}

It just shows that you need to have both RunQuery and InsertQuery in a class that implements the interface IQueryAdapter like the YouHaveAutism class above
 

TheNotorious

Im dying slowly.
Oct 4, 2014
228
41
That's an interface what does that have to do with anything? That just says that if we have something like:
Code:
namespace You.Are.A.Retard
{
    class YouHaveAutism : IQueryAdapter
    {
     quit();
    }
}

It just shows that you need to have both RunQuery and InsertQuery in a class that implements the interface IQueryAdapter like the YouHaveAutism class above
This should work.

Just fixed it little.
 

HolaBox

New Member
Feb 20, 2017
27
2
Ya you are best using the SendNotification one then with the fix I provided unless it does not use dbClient to call the query.

oh i will use the other one then, only reason i wanted @Legit's version is because it lets them know they was sent (You have received {Amount} credits from {Habbo.Username}) as the other just sends it and you dont even know unless you catch it update in the top right :p
 
Jan 7, 2016
194
15
Oh @HolaBox I thought you were talking about the ;usersonline command lol.
 
@Legit 's version should work fine, soz for confusion. But if his does not work then just hit me up in PM and I will find a solution to fix your problem.
 
May 1, 2015
467
152
oh i will use the other one then, only reason i wanted @Legit's version is because it lets them know they was sent (You have received {Amount} credits from {Habbo.Username}) as the other just sends it and you dont even know unless you catch it update in the top right :p
Very simple to do, this command can only be used if the receiving user is in the room so sending a shout which this command does will notify the user.
If you still want to send a notification to the receiving user it can be done like this:
Code:
TargetClient.SendNotification("You have just recieved " + Amount + " credits from " + Session.GetHabbo().Username + "!");
 

JynX

Posting Freak
Feb 6, 2016
710
438
Very simple to do, this command can only be used if the receiving user is in the room so sending a shout which this command does will notify the user.
If you still want to send a notification to the receiving user it can be done like this:
Code:
TargetClient.SendNotification("You have just recieved " + Amount + " credits from " + Session.GetHabbo().Username + "!");
Mine's still coded better ;)
 

HolaBox

New Member
Feb 20, 2017
27
2
Mine's still coded better ;)

I switched back to yours, and added the code to RoomUserManager which allowed the build to pass with no errors but now everyone gets: 'Sorry but you cannot pay this user' error.
 

JynX

Posting Freak
Feb 6, 2016
710
438
I switched back to yours, and added the code to RoomUserManager which allowed the build to pass with no errors but now everyone gets: 'Sorry but you cannot pay this user' error.
Is the sender or receiver a staff member? I made it to where you cannot pay or receive from staff members for obvious reasons.
 
Status
Not open for further replies.

Users who are viewing this thread

Top