Accounts not being removed from userfiles[Y_ini] -
GwENiko - 17.06.2014
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
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;
}
Re: Accounts not being removed from userfiles[Y_ini] -
SickAttack - 18.06.2014
Are you sure that this is correct?
Or is it?
Re: Accounts not being removed from userfiles[Y_ini] -
GwENiko - 18.06.2014
Lol you're right, but for some odd reason, it is still not removing the old userfile o_O
Re: Accounts not being removed from userfiles[Y_ini] -
SickAttack - 18.06.2014
It won't delete the old userfile because the specific file was not found. You didn't format the player's name.
pawn Код:
format(astring, sizeof(astring), "/Users/%s.ini", Name2);
fremove(astring);
And I see that you have lines that aren't necessary. Example: You're formating "format(astring, sizeof(astring), "/Users/%s.ini");" twice.
Re: Accounts not being removed from userfiles[Y_ini] -
GwENiko - 18.06.2014
Well, i tried it like this:
pawn Код:
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(id, Name2, sizeof(Name2));
new INI:file = INI_Open(Path(id));
new cstring[128];
INI_SetTag(file, "User's Data");
GetPlayerName(id, daname, sizeof(daname));
format(astring, sizeof(astring), "/Users/%s.ini", daname);
fremove(astring);
INI_WriteString(file, "Name", newname);
format(cstring, sizeof(cstring), "/Users/%s.ini", newname);
INI_Close(file);
and i still can't get it right :/
Re: Accounts not being removed from userfiles[Y_ini] -
Threshold - 18.06.2014
pawn Код:
CMD:changename(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, -1, "{FF0000}Error: You are not allowed to use this.");
new id, newname[MAX_PLAYER_NAME];
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, -1, "{FFFF00}Usage: /changename <ID> <New Name>");
if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{FF0000}Error: That player is not connected!");
new OldName[MAX_PLAYER_NAME];
GetPlayerName(id, OldName, sizeof(OldName));
if(!SetPlayerName(id, newname))
{
SetPlayerName(id, OldName);
return SendClientMessage(playerid, -1, "You have entered an invalid name.");
}
new Name[MAX_PLAYER_NAME], astring[95];
GetPlayerName(playerid, Name, sizeof(Name));
format(astring, sizeof(astring), "/Users/%s.ini", newname);
if(fexist(astring)) return SendClientMessage(playerid, -1, "<!>Account name is currently in use.");
new INI:file = INI_Open(astring);
INI_SetTag(file, "User's Data");
INI_WriteString(file, "Name", newname);
INI_Close(file);
format(astring, sizeof(astring), "/Users/%s.ini", OldName);
fremove(astring);
SetPVarString(id, "Name", OldName);
format(astring, sizeof(astring), "{0066CC}Admin (%d)%s has changed your name.", playerid, Name);
SendClientMessage(id, -1, astring);
format(astring, sizeof(astring), "{0066CC}You have changed (%d)%s's name to %s.", id, OldName, newname);
SendClientMessage(playerid, -1, astring);
SetTimerEx("KickPlayer", 200, false, "i", id);
return 1;
}
forward KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);
Re: Accounts not being removed from userfiles[Y_ini] -
GwENiko - 18.06.2014
oh i see what i did wrong lol, thanks for the help guys much appreciated.