Skip to content

Instantly share code, notes, and snippets.

@ziggi
Last active February 5, 2024 18:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziggi/5d7d8dc42f54531feba7ae924c608e73 to your computer and use it in GitHub Desktop.
Save ziggi/5d7d8dc42f54531feba7ae924c608e73 to your computer and use it in GitHub Desktop.
Function to calculate the time elapsed between the two calls GetTickCount(), given the possibility of overflow passed values.
stock GetTickDiff(newtick, oldtick)
{
if (oldtick > newtick) {
return (cellmax - oldtick + 1) - (cellmin - newtick);
}
return newtick - oldtick;
}
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;
}
@Vasily-X
Copy link

Vasily-X commented Feb 27, 2019

Isn't GetTickDiff missing code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment