SA-MP Forums Archive
Saving stats on exit... - 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: Saving stats on exit... (/showthread.php?tid=279230)



Saving stats on exit... - Tigerbeast11 - 26.08.2011

I use Xtreme Admin but I don't know how to save the stats on disconnect. Here is the File Variable:

pawn Код:
Variables[playerid][Kills] = GetPlayerFileVar(playerid,"Kills");
Variables[playerid][Deaths] = GetPlayerFileVar(playerid,"Deaths");



Re: Saving stats on exit... - Tanush123 - 26.08.2011

Can't you just add those lines on playerdisconnect?


Re: Saving stats on exit... - Tigerbeast11 - 26.08.2011

Seriously, is that all I have to do?


Re: Saving stats on exit... - =WoR=G4M3Ov3r - 26.08.2011

Quote:
Originally Posted by Tigerbeast11
Посмотреть сообщение
Seriously, is that all I have to do?
Yep, Lol


Re: Saving stats on exit... - Tigerbeast11 - 26.08.2011

It didn't work... I changed the .ini files to make me have 20 deaths. Then I went in game and killed myself twice. I left the game and when I came back, it still said 20 deaths..


Re: Saving stats on exit... - Bakr - 26.08.2011

You are loading the variables with that code, not saving them. How does your script save the data to the files originally?


Re: Saving stats on exit... - Tigerbeast11 - 26.08.2011

I think this is what you mean?
pawn Код:
SetUserInt(playerid,"Registered",1);
                SetUserInt(playerid,"LoggedIn",1);
If it isn't, you can check it yourself. I am using Xtreme Admin. Here is the link:
https://sampforum.blast.hk/showthread.php?tid=286


Re: Saving stats on exit... - =WoR=G4M3Ov3r - 26.08.2011

Quote:
Originally Posted by Tigerbeast11
Посмотреть сообщение
I think this is what you mean?
pawn Код:
SetUserInt(playerid,"Registered",1);
                SetUserInt(playerid,"LoggedIn",1);
If it isn't, you can check it yourself. I am using Xtreme Admin. Here is the link:
https://sampforum.blast.hk/showthread.php?tid=286
What he meant is, the kills and death times you want should save in the .ini, and you didn't set it up.


Re: Saving stats on exit... - Tigerbeast11 - 26.08.2011

I don't know how to save it though; that's why im asking...

under OnPlayerDeath:
pawn Код:
Variables[playerid][Deaths]++;
Variables[killerid][Kills]++;
But I don't really have a way of saving them...


Re: Saving stats on exit... - Basicz - 26.08.2011

I realized XAdmin uses DINI
then

pawn Код:
public OnPlayerConnect( playerid )
{
    Variables[ playerid ][ Kills ] = dini_Int( GetPlayerFile( playerid ), "Kills" );
    Variables[ playerid ][ Deaths ] = dini_Int( GetPlayerFile( playerid ), "Deaths" );

    return 1;
}

public OnPlayerDisconnect( playerid, reason )
{
    dini_IntSet( GetPlayerFile( playerid ), "Kills", Variables[ playerid ][ Kills ] );
    dini_IntSet( GetPlayerFile( playerid ), "Deaths", Variables[ playerid ][ Deaths ] );

    return 1;
}
P.S: GetPlayerFile is defined in XAdmin include.


Re: Saving stats on exit... - Tigerbeast11 - 26.08.2011

It works! Thanks man! +Rep