What's new with this timing system?
Nothing...
How is this timer different from the SetTimer() function?
The only differences is it isn't hardcoded or made into a single function like SetTimer() does.
Can this timer help cover up the holes the SetTimer() function has left? The fact it doesn't have any arguments argument?
That's exactly what it does.
Is this new timer system efficient?
Doubtful, but I think it is accurate enough. I'll run some test and upload screenshots.
I want to try this. Where can I get it?
Over here.
[pawn]#include <time>[/pawn]
[pawn] new interval = 1000; /* Miliseconds */
new repeating = 5; /* Number of times to repeat */
new isDone = 0;
new initTime = tickcount();
new repeated = 0;
while( isDone == 0 )
{
new lastCheckedTime = tickcount();
if( lastCheckedTime - initTime >= interval )
{
initTime = tickcount();
//What you this timer to do when an interval has passed.
repeated++;
if( repeated == repeating )
{
isDone = 1;
}
}
}
return 1;[/pawn]
How do I use this in a function?
Take this sample code as an example.
[pawn]#include <a_vcmp>
#include <time>
forward TestFunction( const argument1[], const argument2[], const argument3[] );
main()
{
print( "TimerTest lock and loaded..." );
}
public OnGameModeInit()
{
TestFunction( "I'm 1st.", "Why am I always 2nd", "Not 3rd again.." );
return 1;
}
public TestFunction( const argument1[], const argument2[], const argument3[] )
{
new interval = 1000; /* Miliseconds */
new repeating = 5; /* Number of times to repeat */
new isDone = 0;
new initTime = tickcount();
new repeated = 0;
while( isDone == 0 )
{
new lastCheckedTime = tickcount();
if( lastCheckedTime - initTime >= interval )
{
initTime = tickcount();
//What you this timer to do when an interval has passed.
print( argument1 );
print( argument2 );
print( argument3 );
repeated++;
if( repeated == repeating )
{
isDone = 1;
}
}
}
return 1;
}[/pawn]
What would that code return?
This is what that code will return.
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..
I'm 1st.
Why am I always 2nd
Not 3rd again..
Credits:Fuzzie(Me)