Problem with save file
#1

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?
Reply
#2

Sorry for hour bump but it's important..
Reply
#3

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

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

What wesley says! :P
Reply
#6

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.
Reply
#7

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
Reply
#8

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

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?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)