04.02.2014, 18:02
Can someone explain me why this command to change name in the message it says the name of the player id 0?
Here:
At "changed %s (%d)" im getting the name of the player id 0, even if the target player has another id.
pawn Код:
CMD:cname(playerid, params[])
{
if(PlayerInfo[playerid][Admin] >= 2)
{
new targetPlayer, newName[MAX_PLAYER_NAME];
new pname[24];
if(sscanf(params, "us[24]", targetPlayer, newName)) return SCM(playerid,-1, "{F70505}Usage: {FFFFFF}/cname <playerid> <new name>");
if(!IsPlayerConnected(targetPlayer))
{
return SendClientMessage(playerid, red, "Invalid playerid.");
}
new clientMessage[128];
GetPlayerName(targetPlayer,pname,sizeof(pname));
format(clientMessage, sizeof(clientMessage), "UPDATE `playerdata` SET `user` = '%s' WHERE `user` = '%s'", sanitize(newName), GetPlayersName(targetPlayer));
mysql_function_query(mysqlc, clientMessage, false, "", "");
SetPlayerName(targetPlayer, "TEMP_CNAME");
SetPlayerName(targetPlayer, newName);
new pstring[128];
format(pstring,sizeof(pstring),"%s (lvl %d) %s (%d) changed %s (%d)'s account name to %s.",AdminLevelToName(playerid),PlayerInfo[playerid][Admin],GetPlayersName(playerid),playerid,pname,targetPlayer,newName);
SendStaffMessage(pink,pstring);
new k[128];
format(k, sizeof(k), "1,8%s (lvl %d) %s (%d) changed %s (%d)'s account name to %s.",AdminLevelToName(playerid),PlayerInfo[playerid][Admin],GetPlayersName(playerid),playerid,pname,targetPlayer,newName);
IRC_GroupSay(gGroupID, IRC_ACHANNEL, k);
}
return 1;
}
pawn Код:
changed %s (%d)'s account name to %s.