19.03.2012, 20:38
Hi.
I've had an idea.
The idea of balanced distribution of timer with the same frequency.
The result is TaskManager.
How does it work?
Just use the following macro in some function:
interval is just the interval of the calling of the functions timer1, timer2, etc.
You can have as many timers as you want.
Now let's assume we have this:
What will happen here?
It's pretty simple! The interval is 1000ms.
~333ms after the call of NewTask<...>(...),
TestA will get executed.
After another 333ms, TestB will be executed.
And again after another 333ms TestC will be executed.
What will happen next?
After another 333ms TestA will get executed again!
So there are 1000ms between the first call of TestA and the second call of TestA!
So...
... what it actually does is:
Take some timers and equally distribute their execution on the desired time interval.
Important!
You can use NewTask as many times as you want in any function.
But you have to make sure that the used intervals are different.
The timers may NOT have arguments!
Download?
TaskManager.inc
ptr.inc (needed)
I've had an idea.
The idea of balanced distribution of timer with the same frequency.
The result is TaskManager.
How does it work?
Just use the following macro in some function:
pawn Код:
NewTask<interval>("timer1", "timer2", ...);
You can have as many timers as you want.
Now let's assume we have this:
pawn Код:
#include <a_samp>
#include <TaskManager>
main() { }
public OnGameModeInit()
{
NewTask<1000>("TestA", "TestB", "TestC");
}
forward TestA();
public TestA()
{
print("TestA!!!");
}
forward TestB();
public TestB()
{
print("TestB!!!");
}
forward TestC();
public TestC()
{
print("TestC!!!");
}
It's pretty simple! The interval is 1000ms.
~333ms after the call of NewTask<...>(...),
TestA will get executed.
After another 333ms, TestB will be executed.
And again after another 333ms TestC will be executed.
What will happen next?
After another 333ms TestA will get executed again!
So there are 1000ms between the first call of TestA and the second call of TestA!
So...
... what it actually does is:
Take some timers and equally distribute their execution on the desired time interval.
Important!
You can use NewTask as many times as you want in any function.
But you have to make sure that the used intervals are different.
The timers may NOT have arguments!
Download?
TaskManager.inc
ptr.inc (needed)