Is there a way to stop gettime();
#1

I'm currently in the way to create a command called "checkafk", which checks for AFK players (here's what I've done now)

pawn Код:
/*As Local*/
new AFKTime[MAX_PLAYERS];


/*Command and stuff*/
public OnPlayerPause(playerid)
{
        //scripts here
    AFK{ playerid } = true;
        AFKTime[playerid] = gettime();
    return 1;
}

public OnPlayerResume(playerid, time)
{
        //scripts here
        //stopping the GETTIME Function
    return 1;
}

CMD:checkafk(playerid,params[] ){
    new count = 0;
    new string[128];
    new names[MAX_PLAYER_NAME];
    GetPlayerName(playerid, names, sizeof(names));
    SendClientMessage(playerid, COLOR_ORANGE,"* AFK(paused) players;");
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            if( AFK{ i } )
            {
                new name[MAX_PLAYER_NAME];
                GetPlayerName(i, name, sizeof(name));
                format(string, sizeof(string), "* %s[%d]", name, i);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                count++;
            }
        }
    }
    if(count == 0)
    {
        SendClientMessage(playerid, COLOR_ORANGE,"* Nobody is AFK(paused)!");
    }
    return 1;
}
But, how can i stop the "gettime" function, when he comes back?
Reply
#2

What do you mean 'stop it'? You can't 'stop' gettime().
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
What do you mean 'stop it'? You can't 'stop' gettime().
;__;
Eh, 1 second timers wouldn't be a good idea, to show for how long the player has been afk, eh?
Reply
#4

Um, increase the 'AFKTime' variable OnPlayerPause(playerid)
You are just getting the current time of pause which isn't really useful, you should increase the variable every SECOND to get 'total' time of being AFK
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)