SA-MP Forums Archive
How to save stuff on GameModExit? - 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: How to save stuff on GameModExit? (/showthread.php?tid=348569)



How to save stuff on GameModExit? - MarinacMrcina - 05.06.2012

How to save stuff on GameModExit?


Re: How to save stuff on GameModExit? - Edward156 - 05.06.2012

You cannot do that but you can save info when OnPlayerDisconnect.


Re: How to save stuff on GameModExit? - MarinacMrcina - 05.06.2012

I made this code on PlayerDisconnect so that it checks if the player has completed registration if not then it deletes the user file of the player and he has to register again.
pawn Код:
if(GetPVarInt(playerid,"Regan")==0)
    {
        new name[MAX_PLAYER_NAME],strPath[128];
        GetPlayerName(playerid,name,sizeof(name));
        format(strPath,sizeof(strPath), "/users/%s.txt",name);
        fremove(strPath);
    }
I Have set SetPVarInt(playerid,"Regan",1) on OnPlayerConnect so if the player disonnect before login his user.txt wont get deleted.

I Have set SetPVarInt(playerid,"Regan",0) on the start of the registration and SetPVarInt(playerid,"Regan",1) when the player finishes it.

Now when I reset my server over /gmx my user.txt in scriptfiles gets deleted.


Re: How to save stuff on GameModExit? - milanosie - 05.06.2012

Quote:
Originally Posted by Edward156
Посмотреть сообщение
You cannot do that but you can save info when OnPlayerDisconnect.
Bullsh*t.

You can save stuff, just not playerdata (UNTESTED, NEVER TRIED THIS)

But its perfectly fine with House systems, Vehicle Systems and stuff like that.


Re: How to save stuff on GameModExit? - iggy1 - 05.06.2012

You can save anything in OnGameModeExit as long as you have it saved in a var. Doesn't matter if it's player data or not, data is data. PVars may not work because players are disconnected when the mode exits (deleting PVars).

I'm guessing they are disconnected before OnGameModeExit is called, since it's the last thing called, i may be wrong.


Re: How to save stuff on GameModExit? - MarinacMrcina - 05.06.2012

So how can i solve my problem then?
Should I just remove the code and risk many angry players that crashed while registering and cant' get their nickname back or what,how do you guys remove the player file if he didn't register corectly?


Re: How to save stuff on GameModExit? - iggy1 - 05.06.2012

Quote:
Originally Posted by MarinacMrcina
Посмотреть сообщение
So how can i solve my problem then?
Should I just remove the code and risk many angry players that crashed while registering and cant' get their nickname back or what,how do you guys remove the player file if he didn't register corectly?
What do you mean if they didn't register correctly? Just don't allow that to happen. Only register their account once they have registered a password, then it wont matter if they crash or not. And save player data once per 2-5 minutes.

EDIT: Use normal vars not PVars.


Re: How to save stuff on GameModExit? - MarinacMrcina - 05.06.2012

I got a dialog registering system.After the player types his password it saves it,after he types his count,character age etc. it saves.

If the player would crash between 2 dialogs then his character wont have age and will be able to buy alcohol in the 24/7s