SA-MP Forums Archive
Is there a way to stop gettime(); - 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: Is there a way to stop gettime(); (/showthread.php?tid=496707)



Is there a way to stop gettime(); - Kyance - 23.02.2014

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?


Re: Is there a way to stop gettime(); - MP2 - 24.02.2014

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


Re: Is there a way to stop gettime(); - Kyance - 24.02.2014

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?


Re: Is there a way to stop gettime(); - LocMax - 24.02.2014

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