pawn Код:
CMD:changename(playerid, params[]) {
new string[84], newname[24], password[40], pName[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pLoggedIn] == 0) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}You need to be logged in to use this command!");
if(GetPlayerCash(playerid) < 20000) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}You need 20'000$ to change your name!");
if(sscanf(params, "s[24]s[40]", newname, password)) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}/changename [NewName] [YourPassword]");
if(udb_hash(password) != PlayerInfo[playerid][pPass]) return SendClientMessage(playerid, COLOR_RED, "* Incorrect password - Password doesn't match!");
GetPlayerName(playerid, pName, sizeof(pName));
if(strcmp(newname, pName) == 0) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}You already have that name..");
format(string, sizeof(string), "/Users/%s.ini", newname);
if(fexist(string)) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}That user-name already exists!");
else
{
/*new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Name-Change info");
INI_WriteString(File,"Previous Name", pName);
INI_WriteString(File,"New Name", newname);
INI_Close(File);*/
format(string, sizeof(string), "/Users/%s.ini", pName);
fremove(string); //Deletes the old name
format(string, sizeof(string), "[NOTE] - %s[%d] changed his name to %s", pName, playerid, newname);
SendMessageToAdmins(COLOR_YELLOW,string);
format(string, sizeof(string), "* Your name has been changed to %s!", newname);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "* Password reminder: %s", password);
SendClientMessage(playerid, -1, string);
printf("%s has changed his name to %s | Password: %s", pName, newname, password);
GivePlayerCash(playerid, -20000);
GetPlayerIp(playerid, ppIP[playerid], 16);
format(string, sizeof(string), "%s", newname);
SetPlayerName(playerid, string);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
//All of your stats/data here
INI_Close(File);
}
return 1;
}