28.12.2013, 04:17
(
Last edited by Emmet_; 01/02/2014 at 04:43 AM.
)
Native function timers!
Introduction
This is just a simple but useful include which allows you to run timers that call native functions. This can be useful for run-time native calling and for many other occasions also, so you don't have to include an extra public function to call one native.
How it works
This works by storing the timer's data in advance, and calls the native after the interval has passed, pushing the arguments onto the stack every call. Say you've had a function like this:
You can improve that using only one line with this include:
Which can be VERY useful and easier in some cases!
Installation
Add this code at the top of your script, preferably under a_samp:
And you're done!
Functions
Notes
Available at my GitHub page - click here.
Introduction
This is just a simple but useful include which allows you to run timers that call native functions. This can be useful for run-time native calling and for many other occasions also, so you don't have to include an extra public function to call one native.
How it works
This works by storing the timer's data in advance, and calls the native after the interval has passed, pushing the arguments onto the stack every call. Say you've had a function like this:
pawn Code:
forward KickPlayer(playerid);
public KickPlayer(playerid)
{
Kick(playerid);
}
SetTimerEx("KickPlayer", 1000, false, "d", playerid);
pawn Code:
Native_Timer("Kick", 1000, false, "d", playerid);
Installation
Add this code at the top of your script, preferably under a_samp:
pawn Code:
#include <a_samp>
#include <ntimers>
Functions
pawn Code:
// Setup a native timer.
forward Native_Timer(function[], interval, repeating, specifiers[] = "", {Float,_}:...);
// Setup a native timer (which is called a specified amount of times).
forward Native_TimerEx(function[], interval, count, specifiers[] = "", {Float,_}:...);
// Kills a native timer.
forward Native_Kill(timerid);
- You cannot use "CallLocalFunction" or "CallRemoteFunction" with Native_Timer.
- Some functions might not be called correctly, but I ensure that 98% of them are very stable.
Available at my GitHub page - click here.