SA-MP Forums Archive
How much time played on Server - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How much time played on Server (/showthread.php?tid=77969)



How much time played on Server - SiJ - 16.05.2009

1. How can I count, how much time player played on server?

2. If I have this timer started:
SetTimer(timer,1200000,false); (20 minutes)
is it possible to see how much time left after few minutes?


Re: How much time played on Server - Weirdosport - 16.05.2009

When the player joins, gettickcount.. when they check, gettickcount again... the difference is thetime he has been there in ms.

EDIT: Alternatively use Gettime which works in seconds and sounds more reliable..

Example:
pawn Код:
#include <a_samp>

new Time[MAX_PLAYERS], string[128];

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

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Time", cmdtext, true, 10) == 0)
    {
        format(string, sizeof(string), "You have been here %d seconds!", gettime() - Time[playerid]);
        SendClientMessage(playerid, 0xFF00FFFF, string);
        return 1;
    }
    return 0;
}
EDIT: No timers, no mess

EDIT: Sorry made a fail somewhere, lemme checkit


Re: How much time played on Server - SiJ - 16.05.2009

Oh thanks..


Re: How much time played on Server - Weirdosport - 16.05.2009

OK, it only works for me when I'm not running debugger.. There must be a reason for this other than the fact they share /time (I checked by changing the command name)