Total minutes
#1

Removed
Reply
#2

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;
}
Reply
#3

Removeds?
Reply
#4

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

Removed
Reply
#6

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

Removed
Reply
#8

Removed
Reply
#9

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;
}
Reply
#10

Ok thanks a lot +rep
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)