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 Q&A
Close This Pls
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="Altercationz" data-source="post: 387549" data-attributes="member: 59038"><p>I have no idea why you're using packets, as it's not needed.</p><p>I've fixed it up a bit for you, tested it & it works fine.</p><p>[CODE]</p><p>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> 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 == 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 = false;</p><p></p><p> Room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false);</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("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + TargetClient.GetHabbo().Id + "', @name, '" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "')");</p><p> dbClient.AddParameter("name", NewName);</p><p> dbClient.RunQuery();</p><p> }</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="Altercationz, post: 387549, member: 59038"] I have no idea why you're using packets, as it's not needed. I've fixed it up a bit for you, tested it & it works fine. [CODE] 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 == 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 = false; Room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false); 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("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + TargetClient.GetHabbo().Id + "', @name, '" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "')"); dbClient.AddParameter("name", NewName); dbClient.RunQuery(); } } } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Close This Pls
Top