This plugin makes timers more accurate. Topic.
This plugin is no longer supported.
Previous versions on the Releases page might have problems and bugs, use at your own risk.
Plugin uses default SA-MP natives so you don't have to change your code. Example:
#include <a_samp>
forward Function();
public Function()
{
printf("Function called after 1 second.");
}
forward FunctionWithArguments(number);
public FunctionWithArguments(number)
{
printf("Function called after 2 seconds. Number: %d", number);
}
main()
{
SetTimer("Function", 1000, false);
SetTimerEx("FunctionWithArguments", 2000, false, "d", 10);
}
native SetCustomTimer(const funcname[], interval, delay, count);
Replacement for a standart native function that includes additional parameters.
- delay - the delay before the timer starts.
- count - count of executions.
Note: if you want timer to repeat put -1 instead of count
.
Example: SetCustomTimer("Test", 1000, 500, -1);
native SetCustomTimerEx(const funcname[], interval, delay, count, const format[], {Float,_}:...);
The same function but with argument passing.
Note: if you want timer to repeat put -1 instead of count
.
Example: SetCustomTimerEx("Test", 1000, 500, -1, "i", 1);
native PauseTimer(timerid);
Stops the timer but doesn't delete it.
Use the ContinueTimer() to start it again.
- Note: the callback will be executed after the time remaining before the call.
native ContinueTimer(timerid);
Continues the timer after pausing.
native AddTimerHandler(timerid, handler[]);
Adds the custom callback for the timer.
For example:
new a = SetTimer("function_1");
AddTimerHandler(a, "function_2");
The timer will execute both callbacks.
- Note: arguments will be passed to both functions.
native RemoveTimerHandler(timerid, handler[]);
Removes the added handler.
Another natives.
native KillAllTimers();
native IsValidTimer(timerid);
native GetTimerInterval(timerid);
native SetTimerInterval(timerid, interval);
native GetTimerRemainingTime(timerid);
native GetCountOfRunningTimers();
Build a shared library is provided for only two platforms.
- First of all you should download CMake from the official site.
- Then clone this repository or download source code from the Releases page.
- Generate project with CMake for MSVC.
- Build generated project (Don't forget to change configuration to Release Win32).
- Install everything you need to build a library (if not installed)
// Ubuntu, Debian, etc
apt-get install cmake
apt-get install git
apt-get install gcc-multilib g++-multilib
// CentOS
yum install cmake
yum install git
yum install gcc-multilib g++-multilib
- Clone this repository
git clone --recursive https://github.com/KashCherry/Timer-Fix-plugin
- Generate project with CMake in this folder or create other one
mkdir build && cd build && cmake ..
- Build generated project with make
make
Licensed under MIT License. Learn more about it here.