Well, if you can code it, that'd be fine, but if not, just give me info on where I could look for the function, I tried using ChangeNameEve t for reference, but it's not working too well.
"UPDATE `users` SET `username`='" + Params[1] + "' WHERE `username`='" + TargetUser.Username + "'"
My guess is he needs more help, bump!You won't learn anything from having someone else do it for you - I'll give you the query; feel free to private message me if you're still struggling.
Run that query through the IQuery Adapter.Code:"UPDATE `users` SET `username`='" + Params[1] + "' WHERE `username`='" + TargetUser.Username + "'"
@FrancisJoseph can probably help ya
The user variables that are cached, automatically are saved upon user disconnect by the emulator.Change Flagme to target client and add a IQuery adapter?
I purposely say this to avoid helping people, I work as a professional Software Engineer & Visual Designer.shiietttt
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, ClientPacket Packet, 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 = Packet.PopString();
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();
}
}
}
}
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();
}
}
}
}
if (NewName == String.Empty)
{
Session.SendWhisper("You must enter a new name for the player!");
return;
}