id 0 name -
Face9000 - 04.02.2014
Can someone explain me why this command to change name in the message it says the name of the player id 0?
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;
}
Here:
pawn Код:
changed %s (%d)'s account name to %s.
At "changed %s (%d)" im getting the name of the player id 0, even if the target player has another id.
Re: id 0 name -
Admigo - 04.02.2014
Is your includes up to date?
Cause i had the same problems but when i updated the includes and recompiled my script the problem was fixed.
Re: id 0 name -
PowerPC603 - 04.02.2014
Upgrade your sscanf to version 2.8.1.
Re: id 0 name -
Face9000 - 04.02.2014
The sscanf is already upgraded. I get this problem just with that command.
Re: id 0 name -
Threshold - 04.02.2014
pawn Код:
CMD:cname(playerid, params[])
{
if(PlayerInfo[playerid][Admin] < 2) return 1;
new targetid, newName[MAX_PLAYER_NAME];
if(sscanf(params, "us[24]", targetid, newName)) return SCM(playerid, 0xF70505FF, "Usage: {FFFFFF}/cname <playerid> <new name>");
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Invalid playerid.");
new clientMessage[128], pname[MAX_PLAYER_NAME];
GetPlayerName(targetid, pname, sizeof(pname));
format(clientMessage, sizeof(clientMessage), "UPDATE `playerdata` SET `user` = '%s' WHERE `user` = '%s'", sanitize(newName), pname);
mysql_function_query(mysqlc, clientMessage, false, "", "");
SetPlayerName(targetPlayer, "TEMP_CNAME");
SetPlayerName(targetPlayer, newName);
format(clientMessage, sizeof(clientMessage), "%s (lvl %d) %s (%d) changed %s (%d)'s account name to %s.", AdminLevelToName(playerid), PlayerInfo[playerid][Admin], GetPlayersName(playerid) ,playerid, pname, targetid, newName);
SendStaffMessage(pink, clientMessage);
strins(clientMessage, "1,8", 0);
IRC_GroupSay(gGroupID, IRC_ACHANNEL, clientMessage);
return 1;
}
This should work, otherwise there is a problem with your sscanf plugin or include.
Re: id 0 name -
Face9000 - 05.02.2014
Thanks.