SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 04/04/2019, 01:17 AM   #101
DarkMatrix
Little Clucker
 
Join Date: May 2018
Posts: 2
Reputation: 3
Default Re: Timer Fix

Since version 1.0.9 it uses starting id 0 instead of 1. Which requires to initialize any vars that should store timer id to -1, otherwise there is huge chance of timer with id 0 being accidentally deleted. This change is not noted in the changelog.

Also reusing ids petty much brakes everything in my understanding. Imagine creating timer that run just once, but then at some point in your code you want to delete that timer if it still exists. You check it with IsValidTimer but some other timer can be already re-using this id and as a result you can delete some random timer that uses the same id again.
DarkMatrix is offline   Reply With Quote
Old 04/04/2019, 05:53 AM   #102
KashCherry
Big Clucker
 
KashCherry's Avatar
 
Join Date: Feb 2018
Location: Estonia
Posts: 58
Reputation: 30
Default Re: Timer Fix

Quote:
Originally Posted by DarkMatrix View Post
Since version 1.0.9 it uses starting id 0 instead of 1. Which requires to initialize any vars that should store timer id to -1, otherwise there is huge chance of timer with id 0 being accidentally deleted. This change is not noted in the changelog.

Also reusing ids petty much brakes everything in my understanding. Imagine creating timer that run just once, but then at some point in your code you want to delete that timer if it still exists. You check it with IsValidTimer but some other timer can be already re-using this id and as a result you can delete some random timer that uses the same id again.
Yes, perhaps I should have warned about it.
More important, this is the proper use of the plugin. Removing a timer that a called once, does it make sense?
I had to make such a system for ids for people who use "local" timers. It's enough to think logically to prevent such mistakes.
Anyway, you can still use 1.0.8 version.

Last edited by KashCherry; 04/04/2019 at 06:41 AM.
KashCherry is offline   Reply With Quote
Old 04/04/2019, 01:13 PM   #103
KashCherry
Big Clucker
 
KashCherry's Avatar
 
Join Date: Feb 2018
Location: Estonia
Posts: 58
Reputation: 30
Default Re: Timer Fix

Quote:
Originally Posted by ****** View Post
Edit: And did you ever fix 0ms timers? Last I saw the code just changed them to 1ms instead, which isn't the same and if people wanted 1ms they could specify that.
I tried to get this error many times, but nothing happened.
And yes you're right about 1ms, it makes no sense because of processtick interval (even with changed sleep).
KashCherry is offline   Reply With Quote
Old 06/04/2019, 10:33 AM   #104
GameOvr
Big Clucker
 
Join Date: Jun 2018
Posts: 151
Reputation: 0
Default Re: Timer Fix

Quote:
Are you sure that public is created? I also need to know which version of YSI are you using.
And list all includes.
pawn Code:
#include <a_samp>

#define     FIXES_ServerVarMsg      0
#define     FIXES_Single            1
#undef      MAX_PLAYERS
#define     MAX_PLAYERS            50

#include <fixes>
#include <playerstats>
#include <playerfuncs>
#include <playercalls>
#include <playerstates>
#include <weaponconfig>
#include <progress2>
#include <YSI\y_ini>
#include <streamer>
#include <zcmd>
#include <foreach>
#include <YSI\y_va>
#include <playerzone>
#include <sscanf2>
#include <easydb>
#include <easyDialog>
#include <TimeStampToDate>
#include <strlib>
//#include <timerfix>

Here's my include list. I'm not sure what the YSI version is, but can you tell me what version sould I use...and about what public are you talking?
GameOvr is offline   Reply With Quote
Old 10/04/2019, 08:06 AM   #105
ReshiramZekrom
Big Clucker
 
ReshiramZekrom's Avatar
 
Join Date: May 2012
Location: Bari, Italy
Posts: 133
Reputation: 14
Default Re: Timer Fix

Quote:
Originally Posted by ****** View Post
Those are both very bad changes, they completely break backwards compatibility with existing code. This was previously a nice drop-in replacement, but can no longer be recommended at all due to these changes.

Edit: And did you ever fix 0ms timers? Last I saw the code just changed them to 1ms instead, which isn't the same and if people wanted 1ms they could specify that.
I agree with ******, this update doesn't make sense for me at all. That's how it always worked and it was quite fine, changing that very little thing forces people to edit their code to fit the plugin while it should be the opposite in this case. I think I'll not move from the 1.0.8 version
__________________
ReshiramZekrom is offline   Reply With Quote
Old 10/04/2019, 12:32 PM   #106
KashCherry
Big Clucker
 
KashCherry's Avatar
 
Join Date: Feb 2018
Location: Estonia
Posts: 58
Reputation: 30
Default Re: Timer Fix

Quote:
Originally Posted by ReshiramZekrom View Post
I agree with ******, this update doesn't make sense for me at all. That's how it always worked and it was quite fine, changing that very little thing forces people to edit their code to fit the plugin while it should be the opposite in this case. I think I'll not move from the 1.0.8 version
I understand. I thought that scripters always lacked such a system for ids, but it looks like it's not. In next versions, there will be no code from 1.0.9
KashCherry is offline   Reply With Quote
Old 23/05/2019, 12:43 PM   #107
KashCherry
Big Clucker
 
KashCherry's Avatar
 
Join Date: Feb 2018
Location: Estonia
Posts: 58
Reputation: 30
Default Re: Timer Fix

Plugin updated to version 1.1.0
- Fixed a problem with invalid timer id (in version 1.0.8 it's 0xFFFF, 0 - now)
- Corrected argument passing
- Make 0 id again invalid (1.0.9)
- Added a 'x/X' format specifier to pass hexacademical numbers
- Added a 't/T' format specifier to pass a timer id (passed by plugin, not developers)
- Added more checks for timer processing

Example of using:
PHP Code:
forward public_timer(numbertimerid);
public 
public_timer(numbertimerid)
{
    
printf("Public called by timer %d. Number: %d"timeridnumber);
}

SetTimerEx("public_timer"1000false"dt"10); 
KashCherry is offline   Reply With Quote
Old 15/06/2019, 11:28 AM   #108
DmitriyShift
Little Clucker
 
Join Date: Jun 2019
Posts: 3
Reputation: 0
Default Re: Timer Fix

Is a plugin problem, the first timer that is released does not work, if the server does not use the plugin then the first timer works.

PHP Code:
public OnGameModeInit() 
{
   
SetTimer("UpDateAll",60000true);
   return 
true;

DmitriyShift is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer ID stored in a variable gets wiped when timer hits ? NeXoR Scripting Help 2 25/03/2017 07:22 PM
Performance Question , Per Player Timer vs Timer that loops through all players BiosMarcel Scripting Help 14 12/12/2016 09:50 AM
If /foodsearch doesn't find item, set wait timer (TIMER HELP) Josh_Main Scripting Help 7 14/09/2016 04:13 PM
Which is better Per Player Timer or Global timer? (issue with timer) Dokins Scripting Help 4 07/06/2016 09:50 AM
Slice's Timer Fix include --> timer public function isn't getting called Riwerry Scripting Help 0 02/01/2016 03:50 PM


All times are GMT. The time now is 01:20 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.