2024-08-05, 08:32 AM
Hello everyone.
I've gotten back into scripting after a long delay and was once again reminded of the issues regarding timers. I am not using any timer plugins (I'll get to that later) so this regards the native 'SetTimer' and 'SetTimerEx'. The inaccuracy of them is one thing, although there is another problem - sometimes the timers are either not calling the function or they are not starting at all. My primary assumption was that something was off with the code, but a specific test I have conducted has proven to me that this might be beyond my control.
I have set up a print/SCM message for a select few functions that timers are supposed to execute, and the proportion is something along the lines of 3-5 times out of 10 the function not being called at all. I have even tried a memory-costing alternative of setting up three timers to call the same function after the same amount of time as an insurance policy, and usually I would get 3 messages back, but sometimes I would get only 2 - one of the timers would not start/call the function. Needless to say I would rather not resort to multiplying timers for the same thing to not cause data packet overload.
For example, this particular code above seemingly needs to return the message three times, but on some occasions it only returns it twice. This is a major obstacle for me.
My question, however, is not whether the native timers are faulty. That's a given. My question would rather be what are the most stable and reputable timer plugins and includes out there? What do you, scripters, personally like to use? This also concerns the accuracy of timers.
We can open a broader discussion from this.
I've gotten back into scripting after a long delay and was once again reminded of the issues regarding timers. I am not using any timer plugins (I'll get to that later) so this regards the native 'SetTimer' and 'SetTimerEx'. The inaccuracy of them is one thing, although there is another problem - sometimes the timers are either not calling the function or they are not starting at all. My primary assumption was that something was off with the code, but a specific test I have conducted has proven to me that this might be beyond my control.
I have set up a print/SCM message for a select few functions that timers are supposed to execute, and the proportion is something along the lines of 3-5 times out of 10 the function not being called at all. I have even tried a memory-costing alternative of setting up three timers to call the same function after the same amount of time as an insurance policy, and usually I would get 3 messages back, but sometimes I would get only 2 - one of the timers would not start/call the function. Needless to say I would rather not resort to multiplying timers for the same thing to not cause data packet overload.
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
SetTimerEx("TestFunction", 1000, false, "i", playerid);
SetTimerEx("TestFunction", 1000, false, "i", playerid);
SetTimerEx("TestFunction", 1000, false, "i", playerid);
return 1;
}
forward TestFunction(playerid);
public TestFunction(playerid)
{
SendClientMessage(playerid, -1, "Test");
return 1;
}
My question, however, is not whether the native timers are faulty. That's a given. My question would rather be what are the most stable and reputable timer plugins and includes out there? What do you, scripters, personally like to use? This also concerns the accuracy of timers.
We can open a broader discussion from this.
"Those who cannot remember the past are condemned to repeat it." - George Sanatayana