[Plus EMU] Custom Rig Command

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Contact Me if you want the Rig Command, Download link expired
 
Last edited:

Pinkman

Posting Freak
Jul 27, 2016
818
194
I dont see how this benefits the hotel but good release. You have some bright ideas and thats what I like about. Ermm Im not sure this will work for every production, correct me if I am wrong.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
I dont see how this benefits the hotel but good release. You have some bright ideas and thats what I like about. Ermm Im not sure this will work for every production, correct me if I am wrong.
It should work for every production. I am making from a normal hotel to a RP, so I have no use for this :) Thanks !
 
Jan 16, 2017
33
0
Please Support me with this?
And where to place first text, and i dont have the Habbo.cs + no text file found in Item.cs as 1.2.3.4.5.6 bla
 

icecafe

Member
Jan 12, 2017
36
2
So correct me if I'm wrong.
First I added the code under the Habbo Class inside of Habbo.cs.
Then I changed the code in Item,cs to the new one you created.
After I created a file in the User command folder called rigdiceCommand.CS and made sure to change the namespace to users.
Finally, I added command_rigdice in my db.

Now, upon a successful build and testing it out it works, somewhat. Command functions, prints out the messages and all, but when rolling the dice it does not stop.

Did I miss something, thanks for the heads up!
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
So correct me if I'm wrong.
First I added the code under the Habbo Class inside of Habbo.cs.
Then I changed the code in Item,cs to the new one you created.
After I created a file in the User command folder called rigdiceCommand.CS and made sure to change the namespace to users.
Finally, I added command_rigdice in my db.

Now, upon a successful build and testing it out it works, somewhat. Command functions, prints out the messages and all, but when rolling the dice it does not stop.

Did I miss something, thanks for the heads up!
That sounds 100% correct. Any errors? I don't think I left out any code.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Verify you created the variable correctly.

Verify that your command will set this variable.

Does the dice work without rigging? Does it work with rigging? or neither?
 

icecafe

Member
Jan 12, 2017
36
2
The command I set does work.
typing :rig <name> <rig order> appears with the message saying the players dice will be rig, blah.
When said player goes to roll, it just keeps rolling.

No it does not worth with out rigging as well. It causes all dice to break.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
The command I set does work.
typing :rig <name> <rig order> appears with the message saying the players dice will be rig, blah.
When said player goes to roll, it just keeps rolling.

No it does not worth with out rigging as well. It causes all dice to break.
Okay, thank you for this information.

Check the Item class and let me see the code for there. Verify that the array in the habbo class is defined and being set properly. The emulator is on my other laptop, so when I return home tomorrow I can verify I did not leave out any code snippets. (Now that I am thinking about it I think there was another one... lmao)
 
Okay add this method to the Item.cs file (or verify it is there)

Code:
public static string[] RandomizeStrings(string[] arr)
        {
            List<KeyValuePair<int, string>> list = new List<KeyValuePair<int, string>>();
            // Add all strings from array
            // Add new random int each time
            foreach (string s in arr)
            {
                list.Add(new KeyValuePair<int, string>(_random.Next(), s));
            }
            // Sort the list by the random number
            var sorted = from item in list
                         orderby item.Key
                         select item;
            // Allocate new string array
            string[] result = new string[arr.Length];
            // Copy values to array
            int index = 0;
            foreach (KeyValuePair<int, string> pair in sorted)
            {
                result[index] = pair.Value;
                index++;
            }
            // Return copied array
            return result;
        }
 

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
I did exactly what you guided, and debugged it via studios, got no errors, still whenever I type :rig or :rigdice, nothing happens and I did add it to the DB as :command_rig + :command_rigdice, does the command.cs file has to match something? like RigDiceCommand.cs or rigdiceCommand.cs?
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
I did exactly what you guided, and debugged it via studios, got no errors, still whenever I type :rig or :rigdice, nothing happens and I did add it to the DB as :command_rig + :command_rigdice, does the command.cs file has to match something? like RigDiceCommand.cs or rigdiceCommand.cs?
No you just have to add the command part that points to the command in the commandManager.cs file?
 

Jaden

not so active
Aug 24, 2014
886
263
I refactored this a bit.

RigDiceCommand.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Rooms.Chat.Commands;

namespace Plus.HabboHotel.Roleplay.Commands.Builder
{
    internal sealed class RigDiceCommand : IChatCommand
    {
        public string PermissionRequired => "command_rigdice";
        public string Parameters => "%username% %sequence%";
        public string Description => "Set predetermined dice outcome(s) without any randomization.";

        public void Execute(GameClient session, Room room, string[] Params)
        {
            if (Params.Length == 1)
            {
                session.SendWhisper("Syntax error! Usage: :rigdice <username> <sequence (0-6, 0-6..)>");
                return;
            }

            // contemplating whether values should be stored in the RoomUser.
            GameClient target = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (target == null)
            {
                session.SendWhisper("Couldn't find user " + Params[1] + " in this room!");
                return;
            }

            // to be used by trusted staff, or convert to array and limit values.
            string input = String.Concat(Params.Skip(2).ToArray()).Replace(" ", string.Empty);

            // pre-allocated memory list configured for 5 insertions.
            List<uint> sequence = new List<uint>(5);

            foreach (string element in input.Split(','))
            {
                uint number;
                if (!uint.TryParse(element, out number))
                {
                    session.SendWhisper(element + " isn't a valid positive integer.");
                    return;
                }

                if (number > 6)
                {
                    session.SendWhisper("Sequence cannot contain numbers greater than 6!");
                    return;
                }

                sequence.Add(number);
            }

            if (target.GetHabbo().DiceSequence != null)
            {
                // add the new sequence to the end of the old sequence (remove if not wanted).
                lock (target.GetHabbo().DiceSequence)
                {
                    List<uint> copySequence = new List<uint>(target.GetHabbo().DiceSequence.Count + sequence.Count);
                    copySequence.AddRange(target.GetHabbo().DiceSequence);
                    copySequence.AddRange(sequence);

                    target.GetHabbo().DiceSequence = copySequence;
                }

                session.SendWhisper("Added to " + target.GetHabbo().Username + "'s current dice sequence.");
                return;
            }

            target.GetHabbo().DiceSequence = sequence;

            // notify the caller that we're finished.
            session.SendWhisper("Created " + target.GetHabbo().Username + "'s dice sequence.");
        }
    }
}

Habbo.cs (Habbo class, I added under the "Just random fun stuff" comment)
Code:
public List<uint> DiceSequence;

My InteractionType.DICE case code
Code:
string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };

if (ExtraData == "-1")
{
    User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);

    if (User.GetClient().GetHabbo().DiceSequence != null)
    {
        ExtraData = User.GetClient().GetHabbo().DiceSequence[0].ToString();
        User.GetClient().GetHabbo().DiceSequence.RemoveAt(0);

        // properly dispose of the DiceSequence list.
        if (!User.GetClient().GetHabbo().DiceSequence.Any())
            User.GetClient().GetHabbo().DiceSequence = null;
    }
    else
    {
        ExtraData = RandomizeStrings(numbers)[0];
    }
}

UpdateState();
 

HolaBox

New Member
Feb 20, 2017
27
2
I refactored this a bit.

RigDiceCommand.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Rooms.Chat.Commands;

namespace Plus.HabboHotel.Roleplay.Commands.Builder
{
    internal sealed class RigDiceCommand : IChatCommand
    {
        public string PermissionRequired => "command_rigdice";
        public string Parameters => "%username% %sequence%";
        public string Description => "Set predetermined dice outcome(s) without any randomization.";

        public void Execute(GameClient session, Room room, string[] Params)
        {
            if (Params.Length == 1)
            {
                session.SendWhisper("Syntax error! Usage: :rigdice <username> <sequence (0-6, 0-6..)>");
                return;
            }

            // contemplating whether values should be stored in the RoomUser.
            GameClient target = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (target == null)
            {
                session.SendWhisper("Couldn't find user " + Params[1] + " in this room!");
                return;
            }

            // to be used by trusted staff, or convert to array and limit values.
            string input = String.Concat(Params.Skip(2).ToArray()).Replace(" ", string.Empty);

            // pre-allocated memory list configured for 5 insertions.
            List<uint> sequence = new List<uint>(5);

            foreach (string element in input.Split(','))
            {
                uint number;
                if (!uint.TryParse(element, out number))
                {
                    session.SendWhisper(element + " isn't a valid positive integer.");
                    return;
                }

                if (number > 6)
                {
                    session.SendWhisper("Sequence cannot contain numbers greater than 6!");
                    return;
                }

                sequence.Add(number);
            }

            if (target.GetHabbo().DiceSequence != null)
            {
                // add the new sequence to the end of the old sequence (remove if not wanted).
                lock (target.GetHabbo().DiceSequence)
                {
                    List<uint> copySequence = new List<uint>(target.GetHabbo().DiceSequence.Count + sequence.Count);
                    copySequence.AddRange(target.GetHabbo().DiceSequence);
                    copySequence.AddRange(sequence);

                    target.GetHabbo().DiceSequence = copySequence;
                }

                session.SendWhisper("Added to " + target.GetHabbo().Username + "'s current dice sequence.");
                return;
            }

            target.GetHabbo().DiceSequence = sequence;

            // notify the caller that we're finished.
            session.SendWhisper("Created " + target.GetHabbo().Username + "'s dice sequence.");
        }
    }
}

Habbo.cs (Habbo class, I added under the "Just random fun stuff" comment)
Code:
public List<uint> DiceSequence;

My InteractionType.DICE case code
Code:
string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };

if (ExtraData == "-1")
{
    User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);

    if (User.GetClient().GetHabbo().DiceSequence != null)
    {
        ExtraData = User.GetClient().GetHabbo().DiceSequence[0].ToString();
        User.GetClient().GetHabbo().DiceSequence.RemoveAt(0);

        // properly dispose of the DiceSequence list.
        if (!User.GetClient().GetHabbo().DiceSequence.Any())
            User.GetClient().GetHabbo().DiceSequence = null;
    }
    else
    {
        ExtraData = RandomizeStrings(numbers)[0];
    }
}

UpdateState();

The type or namespace name 'RigDiceCommand' could not be found (are you missing a using directive or an assembly reference?) when it has ".Builder" on end of namespace is this normal? Changing .Builder to .Fun the breaks client.
 
Last edited:

Users who are viewing this thread

Top