17.04.2015, 09:03
pawn Код:
CMD:setname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GRAD1, " {FF0000}ERROR{FFFFFF}: you do not have sufficient permissions!");
new giveplayerid, newname[MAX_PLAYER_NAME];
if(!sscanf(params, "us[24]", giveplayerid, newname)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/PartOfName] [name]");
if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAD1, " {FF0000}ERROR{FFFFFF}: player is not connected!");
//Perhaps check if the player is logged in and/or registered here?
new string[90];
format(string, sizeof(string), "Accounts/%s.ini", newname);
if(fexist(string)) return SendClientMessage(playerid, COLOR_GRAD1, "That name is already registered.");
new string2[40];
format(string2, sizeof(string2), "Accounts/%s.ini", PlayerName(giveplayerid));
if(INI_Exist(string2)) fremove(string2);
else SendClientMessage(playerid, COLOR_NICERED, "There was a problem with saving the account! Reverting changes...");
//SaveAccounts(); //Wrong. You should be transferring the player's current stats from his current account to the new account
SetPlayerName(giveplayerid, newname);
format(string, sizeof(string), " You have renamed %s to %s !", PlayerName(giveplayerid), newname);
SendInfoMessage(playerid, 2, "0", string);
format(string, sizeof(string), "Your name has been changed from %s to %s.", PlayerName(giveplayerid), newname);
SendInfoMessage(giveplayerid, 2, "0", string);
return 1;
}