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
Server Releases
Delete User & Change Name Commands
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="Hypothesis" data-source="post: 442681" data-attributes="member: 83881"><p>Hi there DevBest, I'd like to release these two pretty useful commands, they were actually quite useful to me and others I have worked with that actually requested these commands be added, and I thought they were pretty good ideas.</p><p><strong>Delete User</strong></p><p><em>Basically this command checks the user table for the username provided and it automatically sets the username of that user to contain random characters, thus not actually deleting the user, but just changing the username to something else, this command was a lot of use to moderators of my hotels, etc.</em></p><p>[CODE=csharp]using System;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Collections.Generic;</p><p></p><p>using Plus.Communication.Packets.Incoming;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Engine;</p><p>using Plus.Communication.Packets.Outgoing.Users;</p><p>using Plus.Database.Interfaces;</p><p>using Plus.HabboHotel.GameClients;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Chat;</p><p>using Plus.Utilities;</p><p>using Plus.HabboHotel.Users;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator</p><p>{</p><p> class</p><p> DeleteUserCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired</p><p> {</p><p> get { return "command_del_user"; }</p><p> }</p><p></p><p> public string Parameters</p><p> {</p><p> get { return "%username%"; }</p><p> }</p><p></p><p> public string Description</p><p> {</p><p> get { return "Allow you to delete a user!"; }</p><p> }</p><p></p><p> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p> if (Params.Length == 1)</p><p> {</p><p> Session.SendWhisper("Please enter the username of the user to delete!");</p><p> return;</p><p> }</p><p> Habbo Habbo = PlusEnvironment.GetHabboByUsername(Params[1]);</p><p> if (Habbo == null)</p><p> {</p><p> Session.SendWhisper("An error occoured whilst finding that user in the database.");</p><p> return;</p><p> }</p><p> if (Session.GetHabbo().Username == Habbo.Username)</p><p> {</p><p> Session.SendWhisper("You cannot delete your own user.", 3);</p><p> return;</p><p> }</p><p></p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.SetQuery("UPDATE `users` SET `username` = '" + Habbo.Username + PlusEnvironment.GetUnixTimestamp() + "' WHERE username ='" + Habbo.Username + "' LIMIT 1");</p><p> dbClient.RunQuery();</p><p> }</p><p> Session.SendWhisper(Habbo.Username + " has been removed from the database!");</p><p></p><p> }</p><p> }</p><p>}[/CODE]</p><p><strong>Change Name</strong></p><p><em>Another very useful command, on my hotel I had flagme for normal players disabled for various reasons</em>, <em>anyways my housekeeping was set to set data by the player's username, so I noticed when changing the username on the user editor, it wouldn't change it properly, because it updated by the username. rather than recoding this to use the user ID, I decided to just create a command in-game for moderators to change a player's name if they did not have the ability to change their name since they didn't have access to the database.</em></p><p>[CODE=csharp]using System;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Collections.Generic;</p><p></p><p>using Plus.Communication.Packets.Incoming;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Engine;</p><p>using Plus.Communication.Packets.Outgoing.Users;</p><p>using Plus.Database.Interfaces;</p><p>using Plus.HabboHotel.GameClients;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator</p><p>{</p><p> class</p><p> ChangeNameCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired</p><p> {</p><p> get { return "command_change"; }</p><p> }</p><p></p><p> public string Parameters</p><p> {</p><p> get { return "%username% %newname%"; }</p><p> }</p><p></p><p> public string Description</p><p> {</p><p> get { return "Change a users name."; }</p><p> }</p><p></p><p> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p> if (Params.Length == 1)</p><p> {</p><p> Session.SendWhisper("Please enter the username of the user you wish to change their name.");</p><p> return;</p><p> }</p><p></p><p> GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);</p><p> if (TargetClient == null)</p><p> {</p><p> Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");</p><p> return;</p><p> }</p><p></p><p> if (TargetClient.GetHabbo() == null)</p><p> {</p><p> Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");</p><p> return;</p><p> }</p><p></p><p></p><p> Room = Session.GetHabbo().CurrentRoom;</p><p> if (Room == null)</p><p> return;</p><p></p><p> RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Username);</p><p> if (User == null)</p><p> return;</p><p></p><p> string NewName = CommandManager.MergeParams(Params, 2);</p><p> string OldName = TargetClient.GetHabbo().Username;</p><p></p><p> if (NewName == String.Empty)</p><p> {</p><p> Session.SendWhisper("You must enter a new name for the player!");</p><p> return;</p><p> }</p><p></p><p> if (NewName == OldName)</p><p> {</p><p> TargetClient.GetHabbo().ChangeName(OldName);</p><p> TargetClient.SendMessage(new UpdateUsernameComposer(NewName));</p><p> return;</p><p> }</p><p></p><p> bool InUse = false;</p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1");</p><p> dbClient.AddParameter("name", NewName);</p><p> InUse = dbClient.getInteger() == 1;</p><p> }</p><p> if (!PlusEnvironment.GetGame().GetClientManager().UpdateClientUsername(Session, OldName, NewName))</p><p> {</p><p> Session.SendNotification("Oops! An issue occoured whilst updating that users name.");</p><p> return;</p><p> }</p><p></p><p> TargetClient.GetHabbo().ChangingName = true;</p><p></p><p> Session.SendWhisper("You have updated " + TargetClient.GetHabbo().Username + "'s username");</p><p> TargetClient.GetHabbo().ChangeName(NewName);</p><p> TargetClient.GetHabbo().GetMessenger().OnStatusChanged(true);</p><p></p><p> TargetClient.SendMessage(new UpdateUsernameComposer(NewName));</p><p> Room.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName));</p><p></p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.SetQuery("UPDATE `users` SET `username`='" + NewName + "' WHERE `id`='" + TargetClient.GetHabbo().Id + "'");</p><p> dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`, `changedby`) VALUES ('" + TargetClient.GetHabbo().Id + "','" + NewName + "','" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "', '" + Session.GetHabbo().Username + "')");</p><p> dbClient.AddParameter("name", NewName);</p><p> dbClient.RunQuery();</p><p> TargetClient.GetConnection().Dispose();</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]</p><p><strong>That's all from me folks! Hopefully these commands will have use to you, and P.S please try to be positive, no negativity such as, "oh this is already on my hotel," or any of that, if you do give criticism, at least back it up with some type of praise, as I really just wanted to give to the smaller developers who can't make such commands, thanks for reading my post!</strong></p></blockquote><p></p>
[QUOTE="Hypothesis, post: 442681, member: 83881"] Hi there DevBest, I'd like to release these two pretty useful commands, they were actually quite useful to me and others I have worked with that actually requested these commands be added, and I thought they were pretty good ideas. [B]Delete User[/B] [I]Basically this command checks the user table for the username provided and it automatically sets the username of that user to contain random characters, thus not actually deleting the user, but just changing the username to something else, this command was a lot of use to moderators of my hotels, etc.[/I] [CODE=csharp]using System; using System.Linq; using System.Text; using System.Collections.Generic; using Plus.Communication.Packets.Incoming; using Plus.Communication.Packets.Outgoing.Rooms.Engine; using Plus.Communication.Packets.Outgoing.Users; using Plus.Database.Interfaces; using Plus.HabboHotel.GameClients; using Plus.Communication.Packets.Outgoing.Rooms.Chat; using Plus.Utilities; using Plus.HabboHotel.Users; namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator { class DeleteUserCommand : IChatCommand { public string PermissionRequired { get { return "command_del_user"; } } public string Parameters { get { return "%username%"; } } public string Description { get { return "Allow you to delete a user!"; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { if (Params.Length == 1) { Session.SendWhisper("Please enter the username of the user to delete!"); return; } Habbo Habbo = PlusEnvironment.GetHabboByUsername(Params[1]); if (Habbo == null) { Session.SendWhisper("An error occoured whilst finding that user in the database."); return; } if (Session.GetHabbo().Username == Habbo.Username) { Session.SendWhisper("You cannot delete your own user.", 3); return; } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `username` = '" + Habbo.Username + PlusEnvironment.GetUnixTimestamp() + "' WHERE username ='" + Habbo.Username + "' LIMIT 1"); dbClient.RunQuery(); } Session.SendWhisper(Habbo.Username + " has been removed from the database!"); } } }[/CODE] [B]Change Name[/B] [I]Another very useful command, on my hotel I had flagme for normal players disabled for various reasons[/I], [I]anyways my housekeeping was set to set data by the player's username, so I noticed when changing the username on the user editor, it wouldn't change it properly, because it updated by the username. rather than recoding this to use the user ID, I decided to just create a command in-game for moderators to change a player's name if they did not have the ability to change their name since they didn't have access to the database.[/I] [CODE=csharp]using System; using System.Linq; using System.Text; using System.Collections.Generic; using Plus.Communication.Packets.Incoming; using Plus.Communication.Packets.Outgoing.Rooms.Engine; using Plus.Communication.Packets.Outgoing.Users; using Plus.Database.Interfaces; using Plus.HabboHotel.GameClients; namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator { class ChangeNameCommand : IChatCommand { public string PermissionRequired { get { return "command_change"; } } public string Parameters { get { return "%username% %newname%"; } } public string Description { get { return "Change a users name."; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { if (Params.Length == 1) { Session.SendWhisper("Please enter the username of the user you wish to change their name."); return; } GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]); if (TargetClient == null) { Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online."); return; } if (TargetClient.GetHabbo() == null) { Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online."); return; } Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Username); if (User == null) return; string NewName = CommandManager.MergeParams(Params, 2); string OldName = TargetClient.GetHabbo().Username; if (NewName == String.Empty) { Session.SendWhisper("You must enter a new name for the player!"); return; } if (NewName == OldName) { TargetClient.GetHabbo().ChangeName(OldName); TargetClient.SendMessage(new UpdateUsernameComposer(NewName)); return; } bool InUse = false; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1"); dbClient.AddParameter("name", NewName); InUse = dbClient.getInteger() == 1; } if (!PlusEnvironment.GetGame().GetClientManager().UpdateClientUsername(Session, OldName, NewName)) { Session.SendNotification("Oops! An issue occoured whilst updating that users name."); return; } TargetClient.GetHabbo().ChangingName = true; Session.SendWhisper("You have updated " + TargetClient.GetHabbo().Username + "'s username"); TargetClient.GetHabbo().ChangeName(NewName); TargetClient.GetHabbo().GetMessenger().OnStatusChanged(true); TargetClient.SendMessage(new UpdateUsernameComposer(NewName)); Room.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName)); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `username`='" + NewName + "' WHERE `id`='" + TargetClient.GetHabbo().Id + "'"); dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`, `changedby`) VALUES ('" + TargetClient.GetHabbo().Id + "','" + NewName + "','" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "', '" + Session.GetHabbo().Username + "')"); dbClient.AddParameter("name", NewName); dbClient.RunQuery(); TargetClient.GetConnection().Dispose(); } } } }[/CODE] [B]That's all from me folks! Hopefully these commands will have use to you, and P.S please try to be positive, no negativity such as, "oh this is already on my hotel," or any of that, if you do give criticism, at least back it up with some type of praise, as I really just wanted to give to the smaller developers who can't make such commands, thanks for reading my post![/B] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
Delete User & Change Name Commands
Top