SA-MP Forums Archive
call 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: call onplayerdisconnect (/showthread.php?tid=408076)



call onplayerdisconnect - ancezas - 16.01.2013

hey, public OnPlayerDisconnect is calling a litle bit after OnGameModeExit, After OnGameModeExit al PVar's are deleting, i'm saving all player information with PVar's on OnPlayerDisconnect but they doesn't save becouse they deleted earlyer in OnGameModeExit so how can i call OnPlayerDisconnect earlyer? to get my info saved?


Re: call onplayerdisconnect - Konstantinos - 16.01.2013

pawn Code:
public OnGameModeExit( )
{
    for( new i = 0; i < MAX_PLAYERS; i++ ) OnPlayerDisconnect( i, 1 );
    return 1;
}



Re: call onplayerdisconnect - ancezas - 16.01.2013

Quote:
Originally Posted by Dwane
View Post
pawn Code:
public OnGameModeExit( )
{
    for( new i = 0; i < MAX_PLAYERS; i++ ) OnPlayerDisconnect( i, 1 );
    return 1;
}
not saving still


Re: call onplayerdisconnect - Konstantinos - 16.01.2013

It does save fine for me. How do you save in OnPlayerDisconnect?


Re: call onplayerdisconnect - ancezas - 16.01.2013

pawn Code:
new Query[ 512 ];

            format( Query, sizeof( Query ),"UPDATE `"#MYSQL_TABLE"` SET pinigai = '%i', patirtis = '%i', admin = '%i', vip = '%i', radija = '%i', nuzudymai = '%i', mirtis = '%i' WHERE vardas = '%s'",
            GetMoney( playerid ),
            GetPatirtis( playerid ),
            zInfo[ playerid ][ Admin ],
            zInfo[ playerid ][ Vip ],
            zInfo[ playerid ][ Radija ],
            zInfo[ playerid ][ Kill ],
            zInfo[ playerid ][ Mirtis ],
            GetPlayerNameEx( playerid ) );

            mysql_query(Query);
            mysql_free_result();
i put your script in gamemode but my saving script is in filterscript


Re: call onplayerdisconnect - Konstantinos - 16.01.2013

It was just an example, I don't know where you're saving to. Replace OnGameModeExit with OnFilterScriptExit and use it to your filterscript. Or if this callback already exists, add the for loop.
It should work fine then.


Re: call onplayerdisconnect - ancezas - 16.01.2013

filterscript isint exiting when gamemode changes


Re: call onplayerdisconnect - Konstantinos - 16.01.2013

Wait man, you made me confused. What do you want to do?


Re: call onplayerdisconnect - ancezas - 16.01.2013

when chaning the mode call OnPlayerDisconnect before OnGameModeExit


Re: call onplayerdisconnect - Konstantinos - 16.01.2013

And about "not saving"? You just told me you're using a system which saves and it's filterscript. OnPlayerDisconnect won't be called if the OnFilterScriptExit won't be called either.

Anyway, what I can suggest you is a timer. Let's say you have the code that it changes the gamemode, instead of that, call OnPlayerDisconnect with the way I showed you above and start a timer with few milliseconds (Not repeated (false). When the timer's callback will be called then change the gamemode.