SA-MP Forums Archive
Problem with save file - 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: Problem with save file (/showthread.php?tid=311351)



Problem with save file - Face9000 - 16.01.2012

Hello,i've a problem with a save some stats in a fine.I used this code to save the total N° of players kills.

Here is:

pawn Код:
new TotalKills;
OnGameModeInit:

pawn Код:
TotalKills = dini_Int("/LOGS/sestats.txt","TotalKills");
OnPlayerDeath:

pawn Код:
TotalKills++;
The problem is,it logs the kills but if i restart the server,the Players Kills Stats are set to 0.How to fix this and save it in a file?


Re: Problem with save file - Face9000 - 16.01.2012

Sorry for hour bump but it's important..


Re: Problem with save file - Wesley221 - 16.01.2012

You probably dont have 'dini_IntSet()' in your script, so it adds one to the variable, but doesnt save in the file.


Re: Problem with save file - Jaxson - 16.01.2012

Add this below "TotalKills++" under OnPlayerDeath callback.
Код:
dini_IntSet("/LOGS/sestats.txt","TotalKills", TotalKills);



Re: Problem with save file - thimo - 16.01.2012

What wesley says! :P


Re: Problem with save file - Face9000 - 16.01.2012

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
You probably dont have 'dini_IntSet()' in your script, so it adds one to the variable, but doesnt save in the file.
So,i've to add the dini_IntSet(TotalKills) under the TotalKills++ variable?

Quote:
Originally Posted by Jaxson
Посмотреть сообщение
Have you loaded the variable mentioned above when player logs in?
OnGameModeInit,not when player login.


Re: Problem with save file - Wesley221 - 16.01.2012

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
So,i've to add the dini_IntSet(TotalKills) under the TotalKills++ variable?



OnGameModeInit,not when player login.
When you restart the server (i assume you restart it with /rcon gmx?), you should add a line under 'OnGameModeExit':
pawn Код:
dini_IntSet(filelocation, "Totalkills", TotalKills);
Not sure what the params are with dini, but should look like this


Re: Problem with save file - Jaxson - 16.01.2012

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
So,i've to add the dini_IntSet(TotalKills) under the TotalKills++ variable?



OnGameModeInit,not when player login.
Yeah, I've just noticed and edited my post.

Quote:
Originally Posted by Jaxson
Посмотреть сообщение
Add this below "TotalKills++" under OnPlayerDeath callback.
Код:
dini_IntSet("/LOGS/sestats.txt","TotalKills", TotalKills);



Re: Problem with save file - Face9000 - 16.01.2012

Thanks,ok then:

pawn Код:
dini_IntSet("/LOGS/sestats.txt","TotalKills", TotalKills);
is to parse TotalKills in the file.

And to read it again if server restarts?


Re: Problem with save file - Jaxson - 16.01.2012

Yes, you need to load the variable again when the server starts. OnGameModeInit callback.