using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace Emulator.HabboHotel.Rooms.Chat.Commands.Administrator
{
class RigCommand : IChatCommand
{
public string PermissionRequired
{
get { return "command_rig"; }
}
public string Parameters
{
get { return "%number%"; }
}
public string Description
{
get { return "Allows you to carry a hand item"; }
}
public void Execute(GameClients.GameClient Session, Room Room, string[] Params)
{
if (!Session.GetHabbo().GetPermissions().HasCommand("command_rig"))
{
Session.SendWhisper("Oops, you do not have the 'command_rig`.");
return;
}
if (Params.Length == 1)
{
Session.SendWhisper("You must enter the number you want to rig. For example; :rig 4 will roll the number 4.");
return;
}
if (!int.TryParse(Convert.ToString(Params[1]), out int Number))
{
Session.SendWhisper("Please enter a valid integer.");
return;
}
Session.GetHabbo().RigDice = true;
Session.GetHabbo().DiceNumber = Number;
Session.SendWhisper("Your dice is now rigged for one roll only.");
}
}
}
private bool _rigDice;
private int _diceNumber;
public bool RigDice
{
get { return this._rigDice; }
set { this._rigDice = value; }
}
public int DiceNumber
{
get { return this._diceNumber; }
set { this._diceNumber = value; }
}
using System;
using Emulator.HabboHotel.Rooms;
using Emulator.HabboHotel.GameClients;
namespace Emulator.HabboHotel.Items.Interactor
{
public class InteractorDice : IFurniInteractor
{
public void OnPlace(GameClient Session, Item Item)
{
if (Item.ExtraData == "-1")
{
Item.ExtraData = "0";
Item.UpdateNeeded = true;
}
}
public void OnRemove(GameClient Session, Item Item)
{
if (Item.ExtraData == "-1")
{
Item.ExtraData = "0";
}
}
public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
{
RoomUser User = null;
if (Session != null)
User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
if (User == null)
return;
if (Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
{
if (Item.ExtraData != "-1")
{
if (Request == -1)
{
Item.ExtraData = "0";
Item.UpdateState();
}
else
{
Item.ExtraData = "-1";
Item.UpdateState(false, true);
if(Session.GetHabbo().DiceNumber > 0)
Item.ExtraData = Convert.ToString(Session.GetHabbo().DiceNumber);
Item.RequestUpdate(3, true);
Session.GetHabbo().DiceNumber = 0;
Session.GetHabbo().RigDice = false;
}
}
}
else
{
User.MoveTo(Item.SquareInFront);
}
}
public void OnWiredTrigger(Item Item)
{
Item.ExtraData = "-1";
Item.UpdateState(false, true);
Item.RequestUpdate(4, true);
}
}
}
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace Emulator.HabboHotel.Rooms.Chat.Commands.Administrator
{
class RigCommand : IChatCommand
{
public string PermissionRequired
{
get { return "command_rig"; }
}
public string Parameters
{
get { return "%number%"; }
}
public string Description
{
get { return "Allows you to rig the next number for yourself"; }
}
public void Execute(GameClients.GameClient Session, Room Room, string[] Params)
{
if (Params.Length == 1)
{
Session.SendWhisper("You must enter the number you want to rig. For example; :rig 4 will roll the number 4.");
return;
}
if (!int.TryParse(Convert.ToString(Params[1]), out int Number))
{
Session.SendWhisper("Please enter a valid integer.");
return;
}
if(Number < 1 || Number > 6){
Session.SendWhisper("Your number must be between 1 and 6");
return;
}
Session.GetHabbo().RigDice = true;
Session.GetHabbo().DiceNumber = Number;
Session.SendWhisper("Your dice is now rigged for one roll only.");
}
}
}
Session.GetHabbo().RigDice = true;
Session.GetHabbo().DiceNumber = Number;
Session.SendWhisper("Your dice is now rigged for one roll only.");
Session.GetHabbo().DiceNumber = Number;
Session.SendWhisper("Your next roll is now rigged for " + Number);
I had the boolean there when I coded it a little differently, when the rig would save for multiple rolls and other plans. I never add the checks and didn't find need, due to only owners having the command, so if you tried anything else, that's just being dumb. Anyhow, if you do plan on letting mods etc use this use JayCustoms code. And no, the original code wasn't removed.Using @Westyy code, I just changed a few things...
1) Description updated
2) Added check for number between 1 and 6
3) Removed check to see if they have a command, its not needed due to the command being loaded into the users commands based on the parameter for permission
Code:using System; using System.Linq; using System.Text; using System.Collections.Generic; namespace Emulator.HabboHotel.Rooms.Chat.Commands.Administrator { class RigCommand : IChatCommand { public string PermissionRequired { get { return "command_rig"; } } public string Parameters { get { return "%number%"; } } public string Description { get { return "Allows you to rig the next number for yourself"; } } public void Execute(GameClients.GameClient Session, Room Room, string[] Params) { if (Params.Length == 1) { Session.SendWhisper("You must enter the number you want to rig. For example; :rig 4 will roll the number 4."); return; } if (!int.TryParse(Convert.ToString(Params[1]), out int Number)) { Session.SendWhisper("Please enter a valid integer."); return; } if(Number < 1 || Number > 6){ Session.SendWhisper("Your number must be between 1 and 6"); return; } Session.GetHabbo().RigDice = true; Session.GetHabbo().DiceNumber = Number; Session.SendWhisper("Your dice is now rigged for one roll only."); } } }
Update: You can actually make this even more tidy by doing this:
Instead of:
Code:Session.GetHabbo().RigDice = true; Session.GetHabbo().DiceNumber = Number; Session.SendWhisper("Your dice is now rigged for one roll only.");
Code:Session.GetHabbo().DiceNumber = Number; Session.SendWhisper("Your next roll is now rigged for " + Number);
Remove the boolean all together (It's not checked in the Item class anyway, its just set to false)
My only concern with this code, is it looks like the original dice code was removed?
if (Item.ExtraData != "-1")
{
if (Request == -1)
{
Item.ExtraData = "0";
Item.UpdateState();
}
else
{
Item.ExtraData = "-1";
Item.UpdateState(false, true);
Item.RequestUpdate(3, true);
}
}