19.05.2014, 19:31
PHP код:
CMD:changename(playerid, params[])
{
new id, newname[MAX_PLAYER_NAME];
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, -1, "USAGE: /changename [playerid] [new name]");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not admin!"); //Change it to your admin enum or whatever
if(IsPlayerConnected(id))
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(id, pname, MAX_PLAYER_NAME);
if(strcmp(pname, newname))
{
SetPlayerName(id, newname);
new string[64];
format(string, sizeof(string), "users/%s.ini", pname); // Your user data folder
fremove(string);
//Then re-save the player
}
else return SendClientMessage(playerid, -1, "Oldname & Newname cannot same!");
}
else return SendClientMessage(playerid, -1, "Player not connected!");
return 1;
}