my commands
Code:using System;
using System.Collections.Generic;
using System.Text;
using Uber.HabboHotel.Items;
using Uber.HabboHotel.GameClients;
using Uber.Messages;
using Uber.HabboHotel.Rooms;
using Uber.Storage;
using System.Data;
namespace Uber.HabboHotel.Misc
{
class ChatCommandHandler
{
public static Boolean Parse(GameClient Session, string Input)
{
string[] Params = Input.Split(' ');
string TargetUser = null;
GameClient TargetClient = null;
Room TargetRoom = null;
RoomUser TargetRoomUser = null;
try
{
int creditsToAdd;
bool GenericMsg;
string Msg;
switch (Params[0].ToLower())
{
#region Debugging/Development
case "update_inventory":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
return true;
}
return false;
case "update_bots":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
UberEnvironment.GetGame().GetBotManager().LoadBots();
return true;
}
return false;
case "update_catalog":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
UberEnvironment.GetGame().GetCatalog().Initialize();
UberEnvironment.GetGame().GetClientManager().BroadcastMessage(new ServerMessage(441));
return true;
}
return false;
case "idletime":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
TargetRoomUser.IdleTime = 600;
return true;
}
return false;
case "t":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
if (TargetRoom == null)
{
return false;
}
TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
if (TargetRoomUser == null)
{
return false;
}
Session.SendNotif("X: " + TargetRoomUser.X + " - Y: " + TargetRoomUser.Y + " - Z: " + TargetRoomUser.Z + " - Rot: " + TargetRoomUser.RotBody);
return true;
}
return false;
case "override":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
if (TargetRoom == null)
{
return false;
}
TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
if (TargetRoomUser == null)
{
return false;
}
if (TargetRoomUser.AllowOverride)
{
TargetRoomUser.AllowOverride = false;
Session.SendNotif("Walking override disabled.");
}
else
{
TargetRoomUser.AllowOverride = true;
Session.SendNotif("Walking override enabled.");
}
return true;
}
return false;
case "update_defs":
if (!Session.GetHabbo().HasFuse("fuse_sysadmin"))
{
return false;
}
UberEnvironment.GetGame().GetItemManager().LoadItems();
Session.SendNotif("Item defenitions reloaded successfully.");
return true;
case "drink":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
if (TargetRoom == null)
{
return false;
}
TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
if (TargetRoomUser == null)
{
return false;
}
try
{
TargetRoomUser.CarryItem(int.Parse(Params[1]));
}
catch (Exception) { }
return true;
}
return false;
case "coins":
case "credits":
if (!Session.GetHabbo().HasFuse("fuse_sysadmin"))
{
return false;
}
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]);
if (TargetClient == null)
{
goto Label_075E;
}
if (!int.TryParse(Params[2], out creditsToAdd))
{
goto Label_0749;
}
TargetClient.GetHabbo().Credits += creditsToAdd;
TargetClient.GetHabbo().UpdateCreditsBalance(true);
TargetClient.SendNotif(Session.GetHabbo().Username + " has awarded you " + creditsToAdd.ToString() + " credits!");
Session.SendNotif("Credit balance updated successfully.");
return true;
return false;
#endregion
#region General Commands
case "whoson":
case "whosonline":
case "online":
{
DataTable onlineData = new DataTable("online");
string message = "Users online:\r";
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
onlineData = dbClient.ReadDataTable("SELECT SQL_NO_CACHE username FROM users WHERE online = '1';");
}
foreach (DataRow user in onlineData.Rows)
{
message = message + user["username"] + "\r";
}
Session.SendNotif(message);
return true;
}
case "pickall":
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
if (TargetRoom != null && TargetRoom.CheckRights(Session, true))
{
List<RoomItem> ToRemove = new List<RoomItem>();
using (TimedLock.Lock(TargetRoom.Items))
{
ToRemove.AddRange(TargetRoom.Items);
}
foreach (RoomItem Item in ToRemove)
{
TargetRoom.RemoveFurniture(Session, Item.Id);
Session.GetHabbo().GetInventoryComponent().AddItem(Item.Id, Item.BaseItem, Item.ExtraData);
}
Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
return true;
}
return false;
case "commands":
String allowedCommands = "Your Commands:\r";
if (Session.GetHabbo().Rank >= 7)
{
allowedCommands += ":update_inventory\r" +
":update_defs -Reload Item settings\r" +
":update_bots\r" +
":update_catalog\r" +
":idletime - Lag?\r" +
":t - Debugging\r" +
":refresh_publics\r" +
":unload <room id>\r" +
":coins/:credits <name> <amount>\r" +
":pixels <name> <amount> \r" +
":givebadge <name> <badge code>\r" +
":poll - For teh lulz\r";
}
if (Session.GetHabbo().Rank >= 6)
{
allowedCommands += ":override - Walking Override\r" +
"::drink <id>\r" +
":ha <message>\r" +
":superban <user> <reason>\r" +
":roomkick <reason>\r";
}
if (Session.GetHabbo().Rank >= 5)
{
allowedCommands += ":ban <user> <time> <reason>\r" +
":roomalert <message>\r" +
":alert <user> <message>\r" +
":mute <user>\r" +
":unmute <user>\r" +
":kick <user> [reason]\r";
}
allowedCommands += ":whoson/:whosonline/:online - Who's online\r" +
":pickall - Pick up all furni\r" +
":commands - This Dialog\r" +
":about - Server Information\r" +
":empty - Clears Inventory";
Session.SendNotif(allowedCommands);
return true;
case "help":
case "info":
case "details":
case "about":
Session.SendNotif ("SpazzEmu Coded for profection, Stability and Power.");
return true;
case "empty":
Session.GetHabbo().GetInventoryComponent().ClearItems();
return true;
#endregion
#region Moderation Commands
case "unload": // :unload <room id> - Unloads the room for updating.
{
if (Session.GetHabbo().HasFuse("fuse_sysadmin"))
{
uint RoomId;
if (uint.TryParse(Params[1], out RoomId))
{
UberEnvironment.GetGame().GetRoomManager().RequestRoomUnload(RoomId);
return true;
}
return false;
}
return false;
}
case "tohotel":
case "alertall":
case "ha":
// Hotel Alert :ha <message>
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
string Notice = Input.Substring(3);
ServerMessage HotelAlert = new ServerMessage(139);
HotelAlert.AppendStringWithBreak("\r\n" + Notice + "\r\n-" + Session.GetHabbo().Username);
UberEnvironment.GetGame().GetClientManager().BroadcastMessage(HotelAlert);
return true;
}
return false;
case "poll":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
ServerMessage Message = new ServerMessage(79);
Message.AppendStringWithBreak("How helpfull was the staff of fixing/dealing with your problem today?");
Message.AppendInt32(5);
Message.AppendInt32(133333);
Message.AppendStringWithBreak("Uber Good");
Message.AppendInt32(2);
Message.AppendStringWithBreak("Very Good");
Message.AppendInt32(3);
Message.AppendStringWithBreak("Good");
Message.AppendInt32(4);
Message.AppendStringWithBreak("Bad");
Message.AppendInt32(5);
Message.AppendStringWithBreak("Very Bad");
Message.AppendInt32(6);
Message.AppendStringWithBreak("No Help At All");
Session.GetHabbo().CurrentRoom.SendMessage(Message);
return true;
}
break;
case "pixels":
if (Session.GetHabbo().Rank < 4)
{
return false;
}
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]);
if (TargetClient == null)
{
goto Label_083F;
}
if (!int.TryParse(Params[2], out creditsToAdd))
{
goto Label_082A;
}
TargetClient.GetHabbo().ActivityPoints += creditsToAdd;
TargetClient.GetHabbo().UpdateActivityPointsBalance(true);
TargetClient.SendNotif(Session.GetHabbo().Username + " has awarded you " + creditsToAdd.ToString() + " Pixels!");
Session.SendNotif("Pixels balance updated successfully.");
return true;
case "givebadge":
if (!Session.GetHabbo().HasFuse("fuse_sysadmin"))
{
return false;
}
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]);
if (TargetClient == null)
{
goto Label_0ABF;
}
TargetClient.GetHabbo().GetBadgeComponent().GiveBadge(UberEnvironment.FilterInjectionChars(Params[2]), true);
return true;
case "invisible":
if (Session.GetHabbo().HasFuse("fuse_admin"))
{
if (Session.GetHabbo().SpectatorMode)
{
Session.GetHabbo().SpectatorMode = false;
Session.SendNotif("Spectator mode disabled. Reload the room to apply changes.");
}
else
{
Session.GetHabbo().SpectatorMode = true;
Session.SendNotif("Spectator mode enabled. Reload the room to apply changes.");
}
return true;
}
return false;
case "ban":
if (Session.GetHabbo().HasFuse("fuse_ban"))
{
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]);
if (TargetClient == null)
{
Session.SendNotif("User not found.");
return true;
}
if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank)
{
Session.SendNotif("You are not allowed to ban that user.");
return true;
}
int BanTime = 0;
try
{
BanTime = int.Parse(Params[2]);
}
catch (FormatException) { }
if (BanTime <= 600)
{
Session.SendNotif("Ban time is in seconds and must be at least than 600 seconds (ten minutes). For more specific preset ban times, use the mod tool.");
}
UberEnvironment.GetGame().GetBanManager().BanUser(TargetClient, Session.GetHabbo().Username, BanTime, MergeParams(Params, 3), false);
return true;
}
return false;
case "superban":
if (Session.GetHabbo().HasFuse("fuse_superban"))
{
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]);
if (TargetClient == null)
{
Session.SendNotif("User not found.");
return true;
}
if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank)
{
Session.SendNotif("You are not allowed to ban that user.");
return true;
}
UberEnvironment.GetGame().GetBanManager().BanUser(TargetClient, Session.GetHabbo().Username, 360000000, MergeParams(Params, 2), false);
return true;
}
return false;
case "roomkick":
if (Session.GetHabbo().HasFuse("fuse_roomkick"))
{
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
if (TargetRoom != null)
{
goto Label_0FDF;
}
}
return false;
case "roomalert":
if (Session.GetHabbo().HasFuse("fuse_roomalert"))
{
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
if (TargetRoom != null)
{
goto Label_10F6;
}
}
return false;
case "mute":
if (!Session.GetHabbo().HasFuse("fuse_mute"))
{
return false;
}
TargetUser = Params[1];
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser);
if ((TargetClient != null) && (TargetClient.GetHabbo() != null))
{
goto Label_1378;
}
Session.SendNotif("Could not find user: " + TargetUser);
return true;
case "unmute":
if (!Session.GetHabbo().HasFuse("fuse_mute"))
{
return false;
}
TargetUser = Params[1];
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser);
if ((TargetClient != null) && (TargetClient.GetHabbo() != null))
{
goto Label_142C;
}
Session.SendNotif("Could not find user: " + TargetUser);
return true;
case "alert":
if (Session.GetHabbo().HasFuse("fuse_alert"))
{
TargetUser = Params[1];
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser);
if (TargetClient == null)
{
Session.SendNotif("Could not find user: " + TargetUser);
return true;
}
TargetClient.SendNotif(MergeParams(Params, 2), Session.GetHabbo().HasFuse("fuse_admin"));
return true;
}
return false;
case "softkick":
case "kick":
if (Session.GetHabbo().HasFuse("fuse_kick"))
{
TargetUser = Params[1];
TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser);
if (TargetClient == null)
{
Session.SendNotif("Could not find user: " + TargetUser);
return true;
}
if (Session.GetHabbo().Rank <= TargetClient.GetHabbo().Rank)
{
Session.SendNotif("You are not allowed to kick that user.");
return true;
}
if (TargetClient.GetHabbo().CurrentRoomId < 1)
{
Session.SendNotif("That user is not in a room and can not be kicked.");
return true;
}
TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(TargetClient.GetHabbo().CurrentRoomId);
if (TargetRoom == null)
{
return true;
}
TargetRoom.RemoveUserFromRoom(TargetClient, true, false);
if (Params.Length > 2)
{
TargetClient.SendNotif("A moderator has kicked you from the room for the following reason: " + MergeParams(Params, 2));
}
else
{
TargetClient.SendNotif("A moderator has kicked you from the room.");
}
return true;
}
return false;
Label_0749:
Session.SendNotif("Please send a valid amount of credits.");
return false;
Label_075E:
Session.SendNotif("User could not be found.");
return false;
Label_082A:
Session.SendNotif("Please send a valid amount of pixels.");
return false;
Label_083F:
Session.SendNotif("User could not be found.");
return false;
Label_0ABF:
Session.SendNotif("User: " + Params[1] + " could not be found in the database.\rPlease try your request again.");
return false;
Label_0FDF:
GenericMsg = true;
string ModMsg = MergeParams(Params, 1);
if (ModMsg.Length > 0)
{
GenericMsg = false;
}
foreach (RoomUser RoomUser in TargetRoom.UserList)
{
if (RoomUser.GetClient().GetHabbo().Rank < Session.GetHabbo().Rank)
{
if (!GenericMsg)
{
RoomUser.GetClient().SendNotif("You have been kicked by an moderator: " + ModMsg);
}
TargetRoom.RemoveUserFromRoom(RoomUser.GetClient(), true, GenericMsg);
}
}
return true;
Label_10F6:
Msg = MergeParams(Params, 1);
foreach (RoomUser RoomUser in TargetRoom.UserList)
{
RoomUser.GetClient().SendNotif(Msg);
}
return true;
Label_1378:
if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank)
{
Session.SendNotif("You are not allowed to (un)mute that user.");
return true;
}
TargetClient.GetHabbo().Mute();
return true;
Label_142C:
if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank)
{
Session.SendNotif("You are not allowed to (un)mute that user.");
return true;
}
TargetClient.GetHabbo().Unmute();
return true;
#endregion
}
}
catch (ExecutionEngineException) { }
return false;
}
public static string MergeParams(string[] Params, int Start)
{
StringBuilder MergedParams = new StringBuilder();
for (int i = 0; i < Params.Length; i++)
{
if (i < Start)
{
continue;
}
if (i > Start)
{
MergedParams.Append(" ");
}
MergedParams.Append(Params[i]);
}
return MergedParams.ToString();
}
}
}

