SA-MP Forums Archive
Total minutes - 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: Total minutes (/showthread.php?tid=394098)



Total minutes - Fernado Samuel - 21.11.2012

Removed


AW: Total minutes - Skimmer - 21.11.2012

I use only one Timer on my Server and it's called SecondTimer.

pawn Код:
pTimes[MAX_PLAYERS]; // Top of the script
forward SecondTimer(); // Top of the script
pawn Код:
SetTimer("SecondTimer", 1000, 1); // Below OnGameModeInit()
pawn Код:
public SecondTimer()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && pInfo[playerid][pLogged] == true) // I'm not sure, is your variable pLogged or not.
        {
            pTimes[i]++;
        }
    }
    return 1;
}
You can save the stats below OnPlayerDisconnect()

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new string[128];
    // Example 'users' is your tablename, you can change it
    format(string, sizeof(string), "UPDATE users SET times = '%d' WHERE username = '%s'", pTimes[playerid], PlayerName(playerid));
    mysql_query(string);
    return 1;
}



Re: Total minutes - Fernado Samuel - 21.11.2012

Removeds?


AW: Total minutes - Skimmer - 21.11.2012

In Game Days or Real Day?

If you want convert it do Game Days (24 minutes = 1 Day), use simple this.

pawn Код:
pTimes[playerid] / 24; // 24 = minutes, example the player has played 86 Minutes, 86 / 24 = 3,5 the server converts it to integer automatically, so it's 3 Game Days



Re: Total minutes - Fernado Samuel - 21.11.2012

Removed


AW: Total minutes - Skimmer - 21.11.2012

Do you mean like this? Example: I played today 12 hours and tommorow again 12 hours. It's total 1 Day.
If you mean this, use simple this function.
pawn Код:
pTimes[playerid] / 1140; // A day has 1140 minutes, 60 * 24 = 1140:



Re: AW: Total minutes - Fernado Samuel - 21.11.2012

Removed


Re: Total minutes - Fernado Samuel - 21.11.2012

Removed


AW: Total minutes - Skimmer - 21.11.2012

Yes, it works too.

pawn Код:
new pJoined[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    new pJoined[playerid] = gettime();
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new value = gettime() - pJoined[playerid];
    printf("The player has played %d minutes.", value);
    return 1;
}



Re: Total minutes - Fernado Samuel - 21.11.2012

Ok thanks a lot +rep