PHP код:
CMD:changename(playerid, params[])
{
new targetid, newname[24], query[256];
if(pInfo[playerid][pAdminLevel] >= 5) {
if(sscanf(params, "ds[24]", targetid, newname)) return SendClientMessage(playerid,-1,""chat" /changename [playerid] [new name]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED,"Error: Player is not connected!");
new n[MAX_PLAYER_NAME];
GetPlayerName(targetid, n, sizeof(n));
SetPlayerName(targetid, newname);
SendClientMessage(targetid, COLOR_RED,"You name has been changed. please re-loggin now.");
new DBResult:dbrResult = db_query(g_dbKeptAlive, query);
format(szQuery, sizeof(szQuery), "UPDATE `users` SET `name` = '%s' WHERE `name` = '%s'", DB_Escape(newname), n);
db_free_result(dbrResult);
}
return 1;
}