Register problems - OnPlayerDisconnect - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Register problems - OnPlayerDisconnect (
/showthread.php?tid=560363)
Register problems - OnPlayerDisconnect -
Razturach - 28.01.2015
Hello!
Problem is the following, whenever I disconect without registering my account it will automaticly make file into Scriptfiles. - I think I'm missing "if" statement but I'm new with y_ini so I have to ask for help.
Code:
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
Failed[playerid] = 0;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
INI_WriteInt(file,"Logins",pInfo[playerid][Logins]);
INI_Close(file);
return 1;
}
Re: Register problems - OnPlayerDisconnect -
nezo2001 - 28.01.2015
If you want to delete his file if he is not registered add under the register dialog
PHP Code:
if(!response) return Kick(playerid);
if(fexist(UserPath(playerid)))
{
fremove(UserPath(playerid));
}
Re: Register problems - OnPlayerDisconnect -
ATGOggy - 28.01.2015
Change to:
PHP Code:
public OnPlayerDisconnect(playerid)
{
Failed[playerid]=0;
if(fexist(Path(playerid)))
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
INI_WriteInt(file,"Logins",pInfo[playerid][Logins]);
INI_Close(file);
}
return 1;
}
Re: Register problems - OnPlayerDisconnect -
Razturach - 28.01.2015
Thank you both for answer, used ATGOggy's code and it's working, helping me to finish my register system will result into repping you (both)
-Raz