Register problems - OnPlayerDisconnect
#1

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;
}
Reply
#2

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));
            } 
Reply
#3

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;

Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)