#1

i am using Yini like this


PHP код:
enum CNR_user
{
    
pPass[129],
    
aLevel,
    
vLevel,
    
pCash,
    
pScore,
    
pKills,
    
pDeaths,
    
phit

PHP код:
stock SaveUserStats(playerid)
{
    if(
IsPlayerConnected(playerid) && IsLoggedIn{playerid} == 1)
    {
        new 
file[40];
        new 
score GetPlayerScore(playerid), cash GetPlayerCash(playerid), wanted GetPlayerWantedLevel(playerid), jail JailTime[playerid];
        new 
Float:armourFloat:health;
        
GetPlayerHealth(playeridhealth);
        
GetPlayerArmour(playeridarmour);
        
PlayerInfo[playerid][pScore] = score;
        
PlayerInfo[playerid][pCash] = cash;
        
PlayerInfo[playerid][pWanted] = wanted;
        
PlayerInfo[playerid][pArmour] = armour;
        
PlayerInfo[playerid][pHealth] = armour;
        
PlayerInfo[playerid][jTime] = jail;
        
GetPlayerArmour(playeridarmour);
        
format(filesizeof(file), USER_FILEGetName(playerid));
        new 
INI:ufile INI_Open(file);
        
INI_WriteString(ufile"pPass"PlayerInfo[playerid][pPass]);
        
INI_WriteInt(ufile"aLevel",PlayerInfo[playerid][aLevel]);
        
INI_WriteInt(ufile"vLevel",PlayerInfo[playerid][vLevel]);
        
INI_WriteInt(ufile"pCash"cash);
        
INI_WriteInt(ufile"pScore"score);
        
INI_WriteInt(ufile"pKills"PlayerInfo[playerid][pKills]);
        
INI_WriteInt(ufile"pDeaths"PlayerInfo[playerid][pDeaths]); 
PHP код:
public LoadUser_data(playeridname[], value[])
{
    
INI_String("pPass"PlayerInfo[playerid][pPass], 129);
    
INI_Int("aLevel"PlayerInfo[playerid][aLevel]);
    
INI_Int("vLevel"PlayerInfo[playerid][vLevel]);
    
INI_Int("pCash"PlayerInfo[playerid][pCash]);
    
INI_Int("pScore"PlayerInfo[playerid][pScore]);
    
INI_Int("pKills"PlayerInfo[playerid][pKills]); 
anybody help for total time stats:


ho wmuhc mins secs and hours player played in server.
Reply
#2

Well, I would do it this way:

Create 2 time variables for the player.
One is for saving the total time the player was on the server, the other is a temporary one for every "session".
The total time variable (like "pTotalTime") is loaded and saved exactly like the other variables you have there (like pKills for example).

in OnPlayerConnect do something like this:

Код:
PlayerInfo[playerid][pTMPTime] = GetTickCount();
in PlayerDisconnect (BEFORE saving the variables to the file):

Код:
PlayerInfo[playerid][pTotalTime] += (GetTickCount() - PlayerInfo[playerid][pTMPTime])/1000;
I would not save the time in milliseconds (as returned by GetTickCount). After some weeks/days of playing the values are getting too big for the capacity of PAWN's integer variables.


Then you have the total time the player played on your server in SECONDS saved in pTotalTime.
You can now either use a time converting function (there are some includes, use search) or convert it yourself.
If you don't know how to do post here again I can explain it to you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)