GetTickCount

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 19:14, 31 July 2015
Ralfie (Talk | contribs)
(Uptime & the fix.)
← Previous diff
Current revision
ZiGGi (Talk | contribs)
(update function for fixes the problem)
Line 7: Line 7:
{{Returns|Uptime of the actual server (not the SA-MP server).}} {{Returns|Uptime of the actual server (not the SA-MP server).}}
-{{note2|GetTickCount will cause problems on servers with uptime of over 24 days as GetTickCount will eventually warp past the integer size constraints. However using [http://pastebin.com/BZyaJpzs This] function fixes the problem.}}+{{note2|GetTickCount will cause problems on servers with uptime of over 24 days as GetTickCount will eventually warp past the integer size constraints. However using [https://gist.github.com/ziggi/5d7d8dc42f54531feba7ae924c608e73 This] function fixes the problem.}}
{{Tip|One common use for GetTickCount is for [http://en.wikipedia.org/wiki/Benchmark_%28computing%29 benchmarking]. It can be used to calculate how much time some code takes to execute. See below for an example.}} {{Tip|One common use for GetTickCount is for [http://en.wikipedia.org/wiki/Benchmark_%28computing%29 benchmarking]. It can be used to calculate how much time some code takes to execute. See below for an example.}}

Current revision



Description:

Returns the uptime of the actual server (not the SA-MP server) in milliseconds.


Parameters:
This function has no parameters.


Return Values:

Uptime of the actual server (not the SA-MP server).


Image:32px-Circle-style-warning.png

Important
Note

GetTickCount will cause problems on servers with uptime of over 24 days as GetTickCount will eventually warp past the integer size constraints. However using This function fixes the problem.


Tip

Image:Light_bulb_icon.png

One common use for GetTickCount is for benchmarking. It can be used to calculate how much time some code takes to execute. See below for an example.


public OnPlayerConnect(playerid)
{
    new count = GetTickCount();
    //Rest of OnPlayerConnect
    printf("Time taken to execute OnPlayerConnect: %d", GetTickCount() - count);
    return 1;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

  • tickcount: Get the uptime of the actual server.
Personal tools