17.06.2014, 23:44
I am so mentally exhausted now, i can't see what i did wrong renaming the player's name, everything works perfect, except for the old userfile is not being deleted! lol.
Also, do ignore the "comic" variable names, it was a joke between me and the other scripter lol
Also, do ignore the "comic" variable names, it was a joke between me and the other scripter lol
pawn Код:
CMD:changename(playerid, params[])
{
new Name[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME], id, bastardname[28], newname[MAX_PLAYER_NAME], BastardName[MAX_PLAYER_NAME], astring[128], daname[MAX_PLAYER_NAME];
BastardName[id] = GetPlayerName(id, newname, sizeof(newname));
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, -1, "{FF0000}Error: You are not allowed to use this.");
if(sscanf(params, "us[64]", id, newname)) return SendClientMessage(playerid, -1, "{FFFF00}Usage: /changename <ID> <New Name>");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{FF0000}Error: That player is not connected!");
{
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(id, Name2, sizeof(Name2));
GetPlayerName(id, daname, sizeof(daname));
format(astring, sizeof(astring), "/Users.ini/%s.ini");
new INI:File = INI_Open(Path(id));
format(astring, sizeof(astring), "/Users.ini/%s.ini");
fremove(astring);
fremove("/Users.ini/%s.ini");
INI_Close(File);
new INI:file = INI_Open(Path(id));
new cstring[128];
INI_SetTag(file, "User's Data");
INI_WriteString(file, "Name", newname);
format(cstring, sizeof(cstring), "/Users/%s.ini", newname);
INI_Close(file);
if(fexist(cstring)) return SendClientMessage(playerid, -1, "<!>Account name is current use.");
GetPVarInt(id, "Name");
SetPVarInt(id, "Name", BastardName[id]);
SetPlayerName(id, newname);
format(cstring, sizeof(cstring), "{0066CC}Admin (%d)%s has changed your name.", playerid, Name);
SendClientMessage(id, -1, cstring);
format(cstring, sizeof(cstring), "{0066CC}You have changed (%d)%s's name.", id, Name2);
SendClientMessage(playerid, -1, cstring);
format(bastardname, sizeof(bastardname), "%s", newname);
Kick(id);
}
return 1;
}