GetTickDiff

GetTickDiff

Description:
Function GetTickDiff calculate the time elapsed between the two calls GetTickCount(), given the possibility of overflow passed values.


Parameters:
(newtick, oldtick)
int newtick Current time.
int oldtick Previous time value.


Return Values:
The function returns the time elapsed between the two values passed to it.


Code:
stock GetTickDiff(newtick, oldtick)
{
    return newtick - oldtick;
}


Examples:
static
    LastShot[MAX_PLAYERS];
 
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new
        current_tick = GetTickCount();
        interval = GetTickDiff(current_tick, LastShot[playerid]);
 
    printf("Last shot interval: %i ms", interval);
 
    LastShot[playerid] = current_tick;
    return 1;
}


Author:
ziggi


Related Functions
The following functions may be useful, as they are related to this function in one way or another.
  • GetTickCount: Returns the uptime of the actual server (not the SA-MP server) in milliseconds.