PDA

View Full Version : Register problems - OnPlayerDisconnect


Razturach
28/01/2015, 11:44 AM
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:
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;
}

nezo2001
28/01/2015, 11:49 AM
If you want to delete his file if he is not registered add under the register dialog
if(!response) return Kick(playerid);
if(fexist(UserPath(playerid)))
{
fremove(UserPath(playerid));
}

ATGOggy
28/01/2015, 11:59 AM
Change to:
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;
}

Razturach
28/01/2015, 12:43 PM
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