[Plugin] Timer Fix
#1

Timer Fix v1.1.1


Description
This plugin makes timers more accurate


Natives
PHP Code:
/*
 * Replacement for a standart native function that includes additional parameters.
 * delay - the delay before the timer starts.
 * count - count of executions.
 */
native SetCustomTimer(funcname[], intervaldelaycount);
/*
 * The same function but with argument passing.
 */
native SetCustomTimerEx(funcname[], delaycount, const format[], {Float,_}:...);
native KillAllTimers();
native IsValidTimer(timerid);
native GetTimerInterval(timerid);
native SetTimerInterval(timeridinterval);
native GetTimerRemainingTime(timerid);
/*
 * Stops the timer but doesn't delete it.
 * Use the ContinueTimer() to start it again.
 * Note: the callback will execute after the time remaining before the call.
 */
native PauseTimer(timerid);
/*
 * Continues the timer after pausing.
 */
native ContinueTimer(timerid);
/*
 * Adds the custom callback for timer.
 * For example:
 * new a = SetTimer("function_1");
 * AddTimerHandler(a, "function_2");
 * The timer will execute both callbacks.
 *
 * Note: arguments will also be passed to both functions.
 */
native AddTimerHandler(timeridhandler[]);
/*
 * Removes the added handler.
 */
native RemoveTimerHandler(timeridhandler[]); 
Example
PHP Code:
#include <timerfix>
new num 0;
new 
timer;
main() {
  
timer SetTimer("callback",1000,true)
}
forward callback();
public 
callback() {
  if(++
num >= 5) {
    if(
IsValidTimer(timer)) KillTimer(timer);
    
SetTimerEx("callbackEx",1000,false,"d",num);
  }
}
forward callbackEx(num);
public 
callbackEx(num) {
  
printf("Num: %d",num);
  
KillAllTimers();

Download
Binaries(Windows, Linux)
Source code
Reply
#2

Looks nice. Have you tested it out? Is it very accurate?
Reply
#3

Quote:
Originally Posted by Sting.
View Post
Looks nice. Have you tested it out? Is it very accurate?
+- 5ms.
Reply
#4

I'd suggest hooking the SetTimer functions and call the plugin's instead in the include, and provide an option to disable that as it's either to use as a plug-play instead of replacing function names, ...

Other than that, good job!
Reply
#5

Plugin updated to version 0.6

- Added hook Timer's natives
Reply
#6

Quote:
Originally Posted by ******
What's the advantage of this version over udan's, YSF's, Slice's, or any other?
As I saw Slice deleted his fix?

Comparisons with this plugin & udan's plugin (5 seconds, Windows x64):
PHP Code:
// this plugin (v0.7)
5000ms
5000ms
5000ms
5000ms
5000ms
// udan's plugin (v1.5)
5004ms
4997ms
5000ms
5004ms
5000ms 
About YSF: I don't know how to test this, can you please do it?

1.) Fixed
2.) Fixed
3.) Fixed
4.) Fixed
5.) Fixed
6.) Fixed

Plugin updated to version 0.7

- Fixed some bugs
- Improved accuracy
Reply
#7

Quote:
Originally Posted by KashCherry
View Post
Timer Fix v0.7


Description
This plugin makes timers more accurate


Natives
PHP Code:
native SetTimer(funcname[], intervalbool:repeat);
native SetTimerEx(funcname[], intervalbool:repeat, const format[], {Float,_}:...);
native KillTimer(const id);
native KillAllTimers(); 
Example
PHP Code:
#include <timerfix>
new num 0;
new 
timer;
main() {
  
timer SetTimer("callback",1000,true)
}
forward callback();
public 
callback() {
  if(++
num >= 5) {
    
KillTimer(timer);
    
SetTimerEx("callbackEx",1000,false,"d",num);
  }
}
forward callbackEx(num);
public 
callbackEx(num) {
  
printf("Num: %d",num);
  
KillAllTimers();

Download
Binaries(Windows, Linux)
Source code
the idea is good ... but when I put this plugin the server blocks the players from connecting.

Code:
[10:57:29]  Loading plugin: timerfix.so
[10:57:29]   Timer Fix plugin v0.7 by KashCherry loaded
[10:57:29]   Loaded.
[10:57:29]  Loaded 9 plugins.

[10:57:29] 
[10:57:29] Filterscripts
[10:57:29] ---------------
[10:57:29]   Loaded 0 filterscripts.

[10:57:30] MySQL baza, a fost conectata!
[10:57:30] 
-----------
Vehicle: 156
MaterialObjects: 112
Objects: 750
DynamicObjects: 2424
Pickps: 20
-----------
[10:57:30] Number of vehicle models: 46
[10:58:24] Kicking 92.119.39.147 because they didn't logon to the game.
[10:58:24] Kicking 200.53.203.103 because they didn't logon to the game.
[10:58:30] [connection] incoming connection: 200.53.203.103:29209 id: 0
[10:58:30] Invalid client connecting from 200.53.203.103
[10:58:30] [connection] incoming connection: 92.119.39.147:54599 id: 1
[10:58:30] [connection] incoming connection: 200.53.203.103:29217 id: 2
[10:58:30] Invalid client connecting from 92.119.39.147
[10:58:30] Invalid client connecting from 200.53.203.103
Reply
#8

Quote:
Originally Posted by Dim4Shift
View Post
the idea is good ... but when I put this plugin the server blocks the players from connecting.

Code:
[10:57:29]  Loading plugin: timerfix.so
[10:57:29]   Timer Fix plugin v0.7 by KashCherry loaded
[10:57:29]   Loaded.
[10:57:29]  Loaded 9 plugins.

[10:57:29] 
[10:57:29] Filterscripts
[10:57:29] ---------------
[10:57:29]   Loaded 0 filterscripts.

[10:57:30] MySQL baza, a fost conectata!
[10:57:30] 
-----------
Vehicle: 156
MaterialObjects: 112
Objects: 750
DynamicObjects: 2424
Pickps: 20
-----------
[10:57:30] Number of vehicle models: 46
[10:58:24] Kicking 92.119.39.147 because they didn't logon to the game.
[10:58:24] Kicking 200.53.203.103 because they didn't logon to the game.
[10:58:30] [connection] incoming connection: 200.53.203.103:29209 id: 0
[10:58:30] Invalid client connecting from 200.53.203.103
[10:58:30] [connection] incoming connection: 92.119.39.147:54599 id: 1
[10:58:30] [connection] incoming connection: 200.53.203.103:29217 id: 2
[10:58:30] Invalid client connecting from 92.119.39.147
[10:58:30] Invalid client connecting from 200.53.203.103
Fixed, download from here.
Reply
#9

Quote:
Originally Posted by KashCherry
View Post
Fixed, download from here.
WOW nice ++! is posible add native IsValidTimer(timerid); ? to bypass this error:

Code:
[12:15:08] [Timer Fix] KillTimer: cannot find timer with id 0
exemple pawn code:
Code:
#define INVALID_TIMER_ID    (0xFFFF)

stock IsValidTimer(timerid) {
	if(timerid != INVALID_TIMER_ID) return true;
	return false;
}
Reply
#10

Plugin updated to version 0.8
- Added native IsValidTimer

You can download this from Releases page
Reply
#11

Quote:
Originally Posted by m4karow
View Post
I use some a few fast timer for animation callbacks, and maybe it will useful for me. i'll try it, thanks!

hmm, okay
Code:
[2018/03/23 14:36:01] [Timer Fix] Cannot call function [EL: 1]
[2018/03/23 14:36:01] [Timer Fix] Cannot call function [EL: 1]
and is there any way to find out which timer have to be killed? a log like in mysql plugin or something like that?
Code:
[2018/03/23 14:36:01] [Timer Fix] KillTimer: cannot find timer with id 0
this could be very useful for bug-fixing
[2018/03/23 14:36:01] [Timer Fix] KillTimer: cannot find timer with id 0


Code:
if(IsValidTimer(timerid))  KillTimer(timerid);
[2018/03/23 14:36:01] [Timer Fix] Cannot call function [EL: 1]

create, please function...
exemple:
Code:
new timerid;
public OnGameModeInit() 
{
 timerid = SetTimer("UpDate",1000, true);
 return true;
}


forward UpDate();
public UpDate() 
{
  if(IsValidTimer(timerid))  KillTimer(timerid);
  return true;
}
Reply
#12

Quote:
Originally Posted by m4karow
View Post
I use some a few fast timer for animation callbacks, and maybe it will useful for me. i'll try it, thanks!

hmm, okay
Code:
[2018/03/23 14:36:01] [Timer Fix] Cannot call function [EL: 1]
[2018/03/23 14:36:01] [Timer Fix] Cannot call function [EL: 1]
and is there any way to find out which timer have to be killed? a log like in mysql plugin or something like that?
Code:
[2018/03/23 14:36:01] [Timer Fix] KillTimer: cannot find timer with id 0
this could be very useful for bug-fixing
What plugins/includes are you using?
Reply
#13

incs: y iters, discord connector, profiler, crashdetect sscanf mysql, 3dtryg, mapandreas, progressbar, smartcmd, audio etc
plugins crashdetect mysql sscanf streamer audio MapAndreas profiler discord-connector
Reply
#14

when I reload gamemode with gmx in the console starts flooding
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:51] [Timer Fix] Timer executing failed
[16:16:52] [Timer Fix] Timer executing failed
[16:16:52] [Timer Fix] Timer executing failed
[16:16:52] [Timer Fix] Timer executing failed
[16:16:52] [Timer Fix] Timer executing failed
Reply
#15

^^ Reason I'm not using it while I will love too when it's fixed.
Reply
#16

There are things I need in this plugin.


GetTimerInterval
SetTimerInterval
SetTimerDelay

These are available in udan's plugin. Can it be added here?
Reply
#17

Plugin updated to version 1.0
- Added natives GetTimerInterval(timerid) & SetTimerInterval(timerid, interval)
- Problem with call callback has been solved (please check)
Reply
#18

Thanks @KashCherry

I have a problem with KillTimer function. Can you check please?
Reply
#19

Quote:
Originally Posted by must006
View Post
Thanks @KashCherry

I have a problem with KillTimer function. Can you check please?
Thank you for report. Fixed. Download from here.
Reply
#20

I use "exit" command in samp-server.exe but don't work. I think SetTimer, SetTimerEx have a bug. I try to login my localhost server and failed:
Code:
Kicking 127.0.0.1 because they didn't logon to the game.
Now, I use v0.9 and no this problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)