Coding Plus Emu Features / Commands

Status
Not open for further replies.

JynX

Posting Freak
Feb 6, 2016
710
438
Isn't ">" checking if the users rank is greater than the number, in this case rank 1?
Yes, so it should check if the receiver or sender is above rank 1 (2+) meaning they are staff and shouldn't be paid in general. I haven't a clue as to why it's still doing that for a rank 1 paying a rank 1
 

HolaBox

New Member
Feb 20, 2017
27
2
It shouldn't, but try removing the:
Code:
            if (Habbo.Rank > 1 || User.Rank > 1)
            {
                Session.SendWhisper("Sorry but you cannot pay this user!");
                return;
            }

This resolved the issue, but of course now allows staff to send :pay now works though after adding // to all that code.
 

C0MB4T122

New Member
Aug 15, 2016
25
0
Can you code a command for staffs like:
Command name = Staffcolor
Function = Changes the color of the staff's name!
 

Marko97

M97 Project based Plus EMU
Aug 7, 2013
99
45
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;
                        }
                    }
            }
        }
    }
}
If you send a negative value, the user target receive a negative balance and the session target receive a positive balance.
For example User1 send -50 diamonds to User2.
User1 obtain +50 diamonds (if User2 have it) and User2 obtain -50 diamonds.

For resolve this issue add under:
Code:
if (Session.GetHabbo().Credits < Amount)
return;
Code:
if (Session.GetHabbo().Duckets < Amount)
return;
Code:
if (Session.GetHabbo().Diamonds < Amount)
return;
THIS CODE:
Code:
if (Amount < 0)
{
Session.SendNotification("You can't send a negative value!");
return;
}
Special thanks Sicily94 ( @xXSicilyXx ) and me for this fix!
 
Last edited:

HolaBox

New Member
Feb 20, 2017
27
2
Is anyone else seeing issues with case-sensitive names? I.e if someone is "Debbie" and I do :pay debbie (lowercase) they don't receive them but they get taken from the user sending?

Does @Marko97's edit need to be edited into @JynX's [ ] or is that fine for negative?
 

Brad

Well-Known Member
Jun 5, 2012
2,319
992
Is anyone else seeing issues with case-sensitive names? I.e if someone is "Debbie" and I do :pay debbie (lowercase) they don't receive them but they get taken from the user sending?

Does @Marko97's edit need to be edited into @JynX's [ ] or is that fine for negative?
use Params[1].ToLower();
 
Also, I came up with a new method of updating balances etc. looks better in my opinion.

Add this to GameClientManager.cs
PHP:
 public void UpdateClientsBalance(GameClient Client, string type, bool add, int amount)
        {
            if (Client == null)
                return;

            switch (type.ToLower())
            {
                case "credits":
                    if (add)
                    {
                        Client.GetHabbo().Credits += amount;
                        Client.SendMessage(new CreditBalanceComposer(Client.GetHabbo().Credits));
                    }
                    else
                    {
                        Client.GetHabbo().Credits -= amount;
                        Client.SendMessage(new CreditBalanceComposer(Client.GetHabbo().Credits));
                    }
                    break;

                case "duckets":
                    if (add)
                    {
                        Client.GetHabbo().Duckets += amount;
                        Client.SendMessage(new HabboActivityPointNotificationComposer(Client.GetHabbo().Duckets, amount));
                    }
                    else
                    {
                        Client.GetHabbo().Duckets -= amount;
                        Client.SendMessage(new HabboActivityPointNotificationComposer(Client.GetHabbo().Duckets, amount));
                    }
                    break;

                case "diamonds":
                    if (add)
                    {
                        Client.GetHabbo().Diamonds += amount;
                        Client.SendMessage(new HabboActivityPointNotificationComposer(Client.GetHabbo().Diamonds, amount, 5));
                    }
                    else
                    {
                        Client.GetHabbo().Diamonds -= amount;
                        Client.SendMessage(new HabboActivityPointNotificationComposer(Client.GetHabbo().Diamonds, amount, 5));
                    }
                    break;
            }
        }

Usage: PlusEnvironment.GetGame().GetClientManager().UpdateClientsBalance(Session, "credits", false, Amount);
 
Last edited:

Hender

King Tinkerer
Mar 3, 2016
304
122
It shouldn't, but try removing the:
Code:
            if (Habbo.Rank > 1 || User.Rank > 1)
            {
                Session.SendWhisper("Sorry but you cannot pay this user!");
                return;
            }
This is lazy AF just give it a permission and add the permissions to what ranks you want in the database. You filthy animal hard coding son of a hoe.
 
Status
Not open for further replies.

Users who are viewing this thread

Top