Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Releases
[Plus EMU] Custom Rig Command
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Jaden" data-source="post: 397892" data-attributes="member: 51705"><p>I refactored this a bit.</p><p></p><p>RigDiceCommand.cs</p><p>[CODE]using System;</p><p>using System.Collections.Generic;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Threading.Tasks;</p><p>using Plus.HabboHotel.GameClients;</p><p>using Plus.HabboHotel.Rooms;</p><p>using Plus.HabboHotel.Rooms.Chat.Commands;</p><p></p><p>namespace Plus.HabboHotel.Roleplay.Commands.Builder</p><p>{</p><p> internal sealed class RigDiceCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired => "command_rigdice";</p><p> public string Parameters => "%username% %sequence%";</p><p> public string Description => "Set predetermined dice outcome(s) without any randomization.";</p><p></p><p> public void Execute(GameClient session, Room room, string[] Params)</p><p> {</p><p> if (Params.Length == 1)</p><p> {</p><p> session.SendWhisper("Syntax error! Usage: :rigdice <username> <sequence (0-6, 0-6..)>");</p><p> return;</p><p> }</p><p></p><p> // contemplating whether values should be stored in the RoomUser.</p><p> GameClient target = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);</p><p></p><p> if (target == null)</p><p> {</p><p> session.SendWhisper("Couldn't find user " + Params[1] + " in this room!");</p><p> return;</p><p> }</p><p></p><p> // to be used by trusted staff, or convert to array and limit values.</p><p> string input = String.Concat(Params.Skip(2).ToArray()).Replace(" ", string.Empty);</p><p></p><p> // pre-allocated memory list configured for 5 insertions.</p><p> List<uint> sequence = new List<uint>(5);</p><p></p><p> foreach (string element in input.Split(','))</p><p> {</p><p> uint number;</p><p> if (!uint.TryParse(element, out number))</p><p> {</p><p> session.SendWhisper(element + " isn't a valid positive integer.");</p><p> return;</p><p> }</p><p></p><p> if (number > 6)</p><p> {</p><p> session.SendWhisper("Sequence cannot contain numbers greater than 6!");</p><p> return;</p><p> }</p><p></p><p> sequence.Add(number);</p><p> }</p><p></p><p> if (target.GetHabbo().DiceSequence != null)</p><p> {</p><p> // add the new sequence to the end of the old sequence (remove if not wanted).</p><p> lock (target.GetHabbo().DiceSequence)</p><p> {</p><p> List<uint> copySequence = new List<uint>(target.GetHabbo().DiceSequence.Count + sequence.Count);</p><p> copySequence.AddRange(target.GetHabbo().DiceSequence);</p><p> copySequence.AddRange(sequence);</p><p></p><p> target.GetHabbo().DiceSequence = copySequence;</p><p> }</p><p></p><p> session.SendWhisper("Added to " + target.GetHabbo().Username + "'s current dice sequence.");</p><p> return;</p><p> }</p><p></p><p> target.GetHabbo().DiceSequence = sequence;</p><p></p><p> // notify the caller that we're finished.</p><p> session.SendWhisper("Created " + target.GetHabbo().Username + "'s dice sequence.");</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p></p><p>Habbo.cs (Habbo class, I added under the "Just random fun stuff" comment)</p><p>[CODE]public List<uint> DiceSequence;[/CODE]</p><p></p><p>My InteractionType.DICE case code</p><p>[CODE]string[] numbers = new string[] { "1", "2", "3", "4", "5", "6" };</p><p></p><p>if (ExtraData == "-1")</p><p>{</p><p> User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);</p><p></p><p> if (User.GetClient().GetHabbo().DiceSequence != null)</p><p> {</p><p> ExtraData = User.GetClient().GetHabbo().DiceSequence[0].ToString();</p><p> User.GetClient().GetHabbo().DiceSequence.RemoveAt(0);</p><p></p><p> // properly dispose of the DiceSequence list.</p><p> if (!User.GetClient().GetHabbo().DiceSequence.Any())</p><p> User.GetClient().GetHabbo().DiceSequence = null;</p><p> }</p><p> else</p><p> {</p><p> ExtraData = RandomizeStrings(numbers)[0];</p><p> }</p><p>}</p><p></p><p>UpdateState();[/CODE]</p></blockquote><p></p>
[QUOTE="Jaden, post: 397892, member: 51705"] 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."); } } } [/CODE] Habbo.cs (Habbo class, I added under the "Just random fun stuff" comment) [CODE]public List<uint> DiceSequence;[/CODE] 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();[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
[Plus EMU] Custom Rig Command
Top