Coding Plus Emu Features / Commands

Status
Not open for further replies.
May 1, 2015
470
154
Hi,
I've seen a thread recently about coding features / commands and I don't believe he has coded one thing,
All i ask is nothing that requires too much work as i don't have time to spend more than 10 minutes on a command / feature.
Just comment below, the command name and basic function.
Thanks!
 
May 1, 2015
470
154
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.Database.Interfaces;
using System.Data;

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 Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                Adapter.SetQuery("SELECT username FROM users WHERE online = '1'");
                Adapter.RunQuery();

                DataTable Table = Adapter.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);
        }
    }
}
 

ZealousOtter

New Member
Feb 17, 2017
16
11
For your online users command, if the hotel has a lot of users online it will cause problems with the notification due to it being a static height. If you want the online user list to be in a scrollable form you can change line 49 from:

Session.SendNotification(Output);
-to-
Session.SendPacket(new MOTDNotificationComposer(Output));

You will also need to include this line below the others at the top of the page:
using Plus.Communication.Packets.Outgoing.Notifications;
 
May 1, 2015
470
154
Coded this pay command for Hobba Hotel, they didn't use it so here you go it's nothing special.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class PayCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_pay"; }
        }
        public string Parameters
        {
            get { return "%username% %currency% %amount%"; }
        }
        public string Description
        {
            get { return "Pay a user credits/diamonds/duckets"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Please enter a currency type! credits/diamonds/duckets.");
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            if (TargetClient == null)
            {
                Session.SendWhisper("That user cannot be found!");
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;
            string Currenices = Params[2];
            switch (Currenices.ToLower())
            {
                case "credits":
                    {
                        int Amount;
                        if (int.TryParse(Params[3], out Amount))
                        {
                            if (Session.GetHabbo().Credits < Amount)
                                return;
                            Session.GetHabbo().Credits -= Amount;
                            Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
                            TargetClient.GetHabbo().Credits += Amount;
                            TargetClient.SendMessage(new CreditBalanceComposer(TargetClient.GetHabbo().Credits));
                            Session.SendMessage(new ShoutComposer(User.VirtualId, "*Pays " + TargetClient.GetHabbo().Username + " " + Amount + " credits*", 0, 0));
                            break;
                        }
                        else
                        {
                            Session.SendWhisper("That seems to be an invalid amount!");
                            break;
                        }
                    }

                case "diamonds":
                    {
                        int Amount;
                        if (int.TryParse(Params[3], out Amount))
                        {
                            if (Session.GetHabbo().Diamonds < Amount)
                                return;
                            Session.GetHabbo().Diamonds -= Amount;
                            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Amount, 5));
                            TargetClient.GetHabbo().Diamonds += Amount;
                            TargetClient.SendMessage(new HabboActivityPointNotificationComposer(TargetClient.GetHabbo().Diamonds, Amount, 5));
                            Session.SendMessage(new ShoutComposer(User.VirtualId, "*Pays " + TargetClient.GetHabbo().Username + " " + Amount + " diamonds*", 0, 0));
                            break;
                        }
                        else
                        {
                            Session.SendWhisper("That seems to be an invalid amount!");
                            break;
                        }
                    }

                case "duckets":
                    {
                        int Amount;
                        if (int.TryParse(Params[3], out Amount))
                        {
                            if (Session.GetHabbo().Duckets < Amount)
                                return;
                            Session.GetHabbo().Duckets -= Amount;
                            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Amount));
                            TargetClient.GetHabbo().Duckets += Amount;
                            TargetClient.SendMessage(new HabboActivityPointNotificationComposer(TargetClient.GetHabbo().Duckets, Amount));
                            Session.SendMessage(new ShoutComposer(User.VirtualId, "*Pays " + TargetClient.GetHabbo().Username + " " + Amount + " duckets*", 0, 0));
                            break;
                        }
                        else
                        {
                            Session.SendWhisper("That seems to be an invalid amount!");
                            break;
                        }
                    }
            }
        }
    }
}
 

Menkz

Member
Jul 9, 2010
374
167
Hey man, could you change the staff alert from a popup alert ( ) to a whisper, with the staff enable (23)
Example:
Here is the command in question:
PHP:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.Communication.Packets.Outgoing.Moderation;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class StaffAlertCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_staff_alert"; }
        }

        public string Parameters
        {
            get { return "%message%"; }
        }

        public string Description
        {
            get { return "Sends a message typed by you to the current online staff members."; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Please enter a message to send.");
                return;
            }

            string Message = CommandManager.MergeParams(Params, 1);
            PlusEnvironment.GetGame().GetClientManager().StaffAlert(new BroadcastMessageAlertComposer("Staff Alert:\r\r" + Message + "\r\n" + "- " + Session.GetHabbo().Username));
            return;
        }
    }
}
 

Velaski

winner
Aug 4, 2015
562
165
Hey man, could you change the staff alert from a popup alert ( ) to a whisper, with the staff enable (23)
Example:
Here is the command in question:
PHP:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.Communication.Packets.Outgoing.Moderation;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class StaffAlertCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_staff_alert"; }
        }

        public string Parameters
        {
            get { return "%message%"; }
        }

        public string Description
        {
            get { return "Sends a message typed by you to the current online staff members."; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Please enter a message to send.");
                return;
            }

            string Message = CommandManager.MergeParams(Params, 1);
            PlusEnvironment.GetGame().GetClientManager().StaffAlert(new BroadcastMessageAlertComposer("Staff Alert:\r\r" + Message + "\r\n" + "- " + Session.GetHabbo().Username));
            return;
        }
    }
}
Because I'm on my computer, I done it for you. Would you want this
You must be registered for see images attach
?
Or the linear one?
 
I coded it the way you showed in the example.
StaffAlertCommand.cs
PHP:
public string PermissionRequired
        {
            get { return "command_staff_alert"; }
        }

        public string Parameters
        {
            get { return "%message%"; }
        }

        public string Description
        {
            get { return "Sends a message typed by you to the current online staff members."; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Please enter a message to send.");
                return;
            }

            string Message = CommandManager.MergeParams(Params, 1);
            PlusEnvironment.GetGame().GetClientManager().StaffAlert("[Staff Alert] " + Message + "" + " - " + Session.GetHabbo().Username);
            return;
        }
}

GameClientManager.cs
Replace

PHP:
  public void StaffAlert(ServerPacket Message, int Exclude = 0)
        {
            foreach (GameClient client in this.GetClients.ToList())
            {
                if (client == null || client.GetHabbo() == null)
                    continue;

                if (client.GetHabbo().Rank < 2 || client.GetHabbo().Id == Exclude)
                    continue;

                client.SendMessage(Message);
            }
        }

with
PHP:
 public void StaffAlert(string Message)
        {
            foreach (GameClient client in this.GetClients.ToList())
            {
                if (client == null || client.GetHabbo() == null)
                    continue;

                if (client.GetHabbo().Rank < 2)
                    continue;

                client.SendWhisper(Message, 23);
            }
        }

 
May 1, 2015
470
154
Thanks man, appreciate that didn't even notice you commented while i was coding it :p
I like the way you did it, for anyone who wants to keep the popup alert and have the whisper alert too this is how i did it,
Code:
public void StaffWhisper(string Whisper, int Exclude = 0)
        {
            foreach (GameClient Client in this.GetClients.ToList())
            {
                if (Client == null || Client.GetHabbo() == null)
                    continue;

                if (Client.GetHabbo().Rank < 2 || Client.GetHabbo().Id == Exclude)
                    continue;

                RoomUser User = Client.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Client.GetHabbo().Id);
                if (User == null)
                    return;

                Client.SendMessage(new WhisperComposer(User.VirtualId, Whisper, 0, 23));
            }
        }
Then you'd just change it to
Code:
PlusEnvironment.GetGame().GetClientManager().StaffWhisper(Message, 0);
 

JynX

Posting Freak
Feb 6, 2016
710
438
My pay command, figured I'd release.
Code:
using Plus.Communication.Packets.Outgoing.Inventory.Purse;
using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class PayCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_pay"; }
        }

        public string Parameters
        {
            get { return "%user% %type% %amount%"; }
        }

        public string Description
        {
            get { return "Pay someone credits/duckets/diamonds!"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room CurrentRoom, string[] Params)
        {
            Habbo Habbo = Session?.GetHabbo();
            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            Habbo User = CurrentRoom?.GetRoomUserManager()?.GetRoomUserByUsername(Params[1])?.GetClient()?.GetHabbo();

            if (Params.Length != 4)
            {
                Session.SendWhisper("Please enter the command in the following format :pay %user% %type% %amount%");
                return;
            }

            if (Habbo.Rank > 1 || User.Rank > 1)
            {
                Session.SendWhisper("Sorry but you cannot pay this user!");
                return;
            }

            if (TargetClient == null)
            {
                Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");
                return;
            }


            if(User == Habbo)
            {
                Session.SendWhisper("You can't give things to yourself.");
                return;
            }

            int Amount = 0;
            if(!int.TryParse(Params[3], out Amount) || Amount <= 0)
            {
                Session.SendWhisper("Please enter a valid amount.");
                return;
            }

            switch(Params[2].ToLower())
            {
                case "credit":
                case "coin":
                case "credits":
                case "coins":

                    if(Habbo.Credits < Amount)
                    {
                        Session.SendWhisper("You don't have enough credits.");
                        return;
                    }

                    Habbo.Credits -= Amount;
                    Session.SendMessage(new CreditBalanceComposer(Habbo.Credits));
                    User.Credits += Amount;
                    User.GetClient().SendMessage(new CreditBalanceComposer(User.Credits));

                    Session.SendNotification($"You have sent {User.Username} {Amount} credits");
                    User.GetClient().SendNotification($"You have received {Amount} credits from {Habbo.Username}");

                    return;

                case "duckets":
                case "pixels":
                case "ducket":
                case "pixel":
                    if (Habbo.Duckets < Amount)
                    {
                        Session.SendWhisper("You don't have enough duckets.");
                        return;
                    }

                    Habbo.Duckets -= Amount;
                    Session.SendMessage(new HabboActivityPointNotificationComposer(Habbo.Duckets, Amount * -1));
                    User.Duckets += Amount;
                    User.GetClient().SendMessage(new HabboActivityPointNotificationComposer(User.Duckets, Amount));

                    Session.SendNotification($"You have sent {User.Username} {Amount} duckets");
                    User.GetClient().SendNotification($"You have received {Amount} duckets from {Habbo.Username}");

                    return;

                case "diamond":
                case "diamonds":

                    if (Habbo.Diamonds < Amount)
                    {
                        Session.SendWhisper("You don't have enough diamonds.");
                        return;
                    }

                    Habbo.Diamonds -= Amount;
                    Session.SendMessage(new HabboActivityPointNotificationComposer(Habbo.Diamonds, Amount * -1, 5));
                    User.Diamonds += Amount;
                    User.GetClient().SendMessage(new HabboActivityPointNotificationComposer(User.Diamonds, Amount, 5));

                    Session.SendNotification($"You have sent {User.Username} {Amount} diamonds");
                    User.GetClient().SendNotification($"You have received {Amount} diamonds from {Habbo.Username}");


                    return;

                default:
                    Session.SendWhisper("You have entered an invalid currency");
                    return;
            }

        }
    }
}
 
Status
Not open for further replies.

Users who are viewing this thread

Top