10.05.2013, 18:04
I have this command and when I try to use it in-game it doesn't respond with anything. In other words, it doesn't work, so what's the problem ? Here is the code
Thanks in advance.
pawn Код:
CMD:changename(playerid,params[])
{
if(pInfo[playerid][pAdminLevel] >= 4)
{
new targetid,newname[24],reason[105],string[256];
if(sscanf(params, "ds[24]s[105]",targetid,newname,reason)) return SendClientMessage(playerid,-1,""chat" /changename [ID] [New Name] [Reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
new escapename[24], Query[128];
mysql_real_escape_string(newname, escapename);
format(Query, sizeof(Query), "SELECT `user` FROM `playerinfo` WHERE `user` = '%s' LIMIT 1", escapename);
mysql_query(Query);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `user`= '%s' WHERE `user` ='%s'",escapename,PlayerName(targetid));
mysql_query(Query);
SetPlayerName(targetid,escapename);
format(string,sizeof(string),""chat""COL_LIGHTBLUE" %s %s changed your name to %s [Reason: %s]",GetAdminName(playerid),PlayerName(playerid),newname, reason);
SendClientMessage(targetid,-1,string);
format(string,sizeof(string),""chat" You've changed ID %d name to %s [Reason: %s]",targetid, PlayerName(targetid), reason);
SendClientMessage(playerid,-1,string);
}
else if(rows == 1)
{
SendClientMessage(playerid, -1, ""chat" This name already exists!");
}
mysql_free_result();
}
else {
SendClientMessage(playerid,-1,""chat""COL_GREY" You are not authorized to use this command");
}
return 1;
}