23.08.2016, 07:09
Hello all, I create /cname command but the problem is it creates a new user id and the old id still exists. Need help with how to fix it.
PHP код:
CMD:cname(playerid, params[])
{
LoginCheck(playerid);
LevelCheck(playerid, 3);
new
string[128],
id,
newname[24]
;
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "<!> [Error] /cname [playerid] [new name]");
if(strlen(newname) < 3 || strlen(newname) > MAX_PLAYER_NAME) return SendClientMessage(playerid, COLOR_RED, "[Error] Invalid Name Length.");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[Error] Player not connected.");
if(User[playerid][accountAdmin] < User[id][accountAdmin]) return SendClientMessage(playerid, COLOR_RED, "[Error] You cannot use this command on higher admin.");
SaveData(id);
User[id][accountLogged] = false;
#if LOG == true
format(string, sizeof string, "Administrator %s has set %s's name to %s", pName(playerid), pName(id), newname);
SaveLog("account.txt", string);
#endif
format(string, sizeof(string), "You have set \"%s's\" name to \"%s\".", pName(id), newname); SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "Administrator \"%s\" has set your name to \"%s\".", pName(playerid), newname); SendClientMessage(id, COLOR_YELLOW, string);
SetPlayerName(id, newname);
SendClientMessage(id, -1, "You have been logged out from your current account, Reconnecting to the server...");
return 1;
}