14.01.2013, 15:05
pawn Код:
CMD:changename(playerid,params[])
{
if(pInfo[playerid][pAdminLevel] >= 4)
{
new targetid,newname[24],string[256];
if(sscanf(params, "ds[24]",targetid,newname)) return SendClientMessage(playerid,-1,"/changename [ID] [New Name]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1," 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, newname);
format(string,sizeof(string),""COL_LIGHTBLUE" %s %s changed your name to %s",GetAdminName(playerid),PlayerName(playerid),newname);
SendClientMessage(targetid,-1,string);
format(string,sizeof(string),"You've changed ID %d name to %s",targetid, PlayerName(targetid));
SendClientMessage(playerid,-1,string);
}
else if(rows == 1)
{
SendClientMessage(playerid, -1, " This name already exists!");
}
mysql_free_result();
}
else {
SendClientMessage(playerid,-1,""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
}
return 1;
}
if(sscanf(params, "ds[24]",targetid,newname)) return SendClientMessage(playerid,-1,""chat" /changename [ID] [New Name]");