How do i record the amount of time player has spent in the server?
#2

Try this:
pawn Код:
enum pInfo
{
    pHours, //put this on your enum, this is just an example
    pMinutes, // <<
    pSeconds, // <<
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerConnect(playerid)
{
    SetTimerEx("TimePlayed", 1000, true, "i", playerid); //set a timer to count player' time played
    return 1;
}

forward TimePlayed(playerid);
public TimePlayed(playerid)
{
    PlayerInfo[playerid][pSeconds]++; //+ player secs
    if(PlayerInfo[playerid][pSeconds] == 60) //check if their secs equal to 60
    {
        PlayerInfo[playerid][pSeconds] = 0; //reset the secs
        PlayerInfo[playerid][pMinutes]++; //convert the secs to minutes
        if(PlayerInfo[playerid][pMinutes] == 60) //check if their minutes equal to 60
        {
            PlayerInfo[playerid][pMinutes] = 0; //reset the minutes
            PlayerInfo[playerid][pHours]++; //convert the minues to hours
        }
    }
    return 1;
}

if(PlayerInfo[playerid][pHours] < 5) return SendClientMessage(playerid, -1, "ERROR: You can't give money if your time played less than 5 hours."); //put this on your give money commands
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)