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



OnPlayerDisconnect. - Shetch - 10.04.2012

Hey there!

I have a question about OnPlayerDisconnect.
If a player crashes, does the OnPlayerDisconnect get called? So i have a saving system, should i just put the saving files under OnPlayerDisconnect and OnGamemodeExit, or just leave it on a timer?


Re: OnPlayerDisconnect. - VenomXNL - 10.04.2012

Hi,

I use my own function called SaveGame(playerid); on OnPlayerDisconnect
and when something important had happend to the player (death, got an achievement etc)

We've created allot of unlockables in our GM so we save when the player obtains one, this is just
to prevent dataloss in a rare case that the server crashes, normaly they only save on my server using
OnPlayerDisconnect()

And this works fine in our case.

[Edited Post because of Crappy english :P]


Re: OnPlayerDisconnect. - VenomXNL - 11.04.2012

If my answer helped you, could you please +rep me?
If you have any other questions regarding the savegame system please let me know

Thanks in advance,


Respuesta: OnPlayerDisconnect. - [DOG]irinel1996 - 11.04.2012

Yes, it's called.
If you play in a RP server (GF edit), crash and reconnect. You'll see what happenes.
Well, player crashes, OnPlayerDisconnect is called and a variable is set to 1 and saved. When he reconnect he'll spawn where he crashed and the variable is set to 0.

Best regards!


Re: OnPlayerDisconnect. - Skribblez - 11.04.2012

If it's player-related, you really have to save data under OnPlayerDisconnect(), and for all the other stuff which needs saving, put them under OnGameModeExit() although, it's best to save a player's data on both, so whenever the game-mode exits or restarts, you have the assurance that they've been saved.