Timer runs 30times instead of forever(using fixes2 plugin)
#1

So i start this timer OnGameModeInit
pawn Код:
SetTimer_("OnPlayerPayday",1,3600*1000,-1);
If my calculations are correct, thats an hour...

Then i added some prints under the "OnPlayerPayday" function, and look what happens
pawn Код:
[19:04:02] Counter under OnPlayerPayday:1
[19:04:02] Counter under OnPlayerPayday:2
[19:04:02] Counter under OnPlayerPayday:3
[19:04:02] Counter under OnPlayerPayday:4
[19:04:02] Counter under OnPlayerPayday:5
[19:04:02] Counter under OnPlayerPayday:6
[19:04:02] Counter under OnPlayerPayday:7
[19:04:02] Counter under OnPlayerPayday:8
[19:04:02] Counter under OnPlayerPayday:9
[19:04:02] Counter under OnPlayerPayday:10
[19:04:02] Counter under OnPlayerPayday:11
[19:04:02] Counter under OnPlayerPayday:12
[19:04:02] Counter under OnPlayerPayday:13
[19:04:02] Counter under OnPlayerPayday:14
[19:04:02] Counter under OnPlayerPayday:15
[19:04:02] Counter under OnPlayerPayday:16
[19:04:02] Counter under OnPlayerPayday:17
[19:04:02] Counter under OnPlayerPayday:18
[19:04:02] Counter under OnPlayerPayday:19
[19:04:02] Counter under OnPlayerPayday:20
[19:04:02] Counter under OnPlayerPayday:21
[19:04:02] Counter under OnPlayerPayday:22
[19:04:02] Counter under OnPlayerPayday:23
[19:04:02] Counter under OnPlayerPayday:24
[19:04:02] Counter under OnPlayerPayday:25
[19:04:02] Counter under OnPlayerPayday:26
[19:04:02] Counter under OnPlayerPayday:27
[19:04:02] Counter under OnPlayerPayday:28
[19:04:02] Counter under OnPlayerPayday:29
[19:04:02] Counter under OnPlayerPayday:30
As you might notice, it's printed not once in an hour. It's printed just after it's started. But why 30 times? Yesterday it was 45 times and i don't remember changing anything...

Note that i'm using https://sampforum.blast.hk/showthread.php?tid=375925 this plugin and it's "SetTimer_" native
Reply
#2

Maybe this sounds silly question, but does OnPlayerPayDay have more params, like playerid?
Is it forwarded?
Can't find any calculation problems though.

Edit: If nothing is wrong with that, I'd advise you to just call the function without timer under OnGameModeInit, and set the timer at at the end of that function. Example:
pawn Код:
public OnGameModeInit()
{
    OnPlayerPayDay();
    return 1;
}
public OnPlayerPayDay()
{
    // Payday function stuff like GivePlayerMoney etc...
    SetTimer_("OnPlayerPayDay", 3600*1000, 3600*1000, 1);  // Not -1 here! That will call many timers.
}
Reply
#3

Ofcourse it's forwarded, and no, no parameters...
Reply
#4

Out of nowhere, the counter now counts to 49...
Reply
#5

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
Edit: If nothing is wrong with that, I'd advise you to just call the function without timer under OnGameModeInit, and set the timer at at the end of that function. Example:
pawn Код:
public OnGameModeInit()
{
    OnPlayerPayDay();
}
public OnPlayerPayDay()
{
    // Payday function stuff like GivePlayerMoney etc...
    SetTimer_("OnPlayerPayDay", 3600*1000, 3600*1000, 1);  // Not -1 here! That will call many timers.
}
Did you try this?
Reply
#6

WOW, things got even weirder. Not it runs forever, and i don't mean forever with an interval of 1hour. It's called over and over..
Reply
#7

What about switching to the classic SetTimer instead?
Reply
#8

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
What about switching to the classic SetTimer instead?
The problem remains. I used standart SetTimer before, then i switched to the plugin one. It used to work alright before.


EDIT: also just tried removing the plugin and using classic SetTimer/SetTimerEx, didn't help.
Tried to remove all of the other code under OnPlayerPayday, didn't change anything either
Reply
#9

This is so weird. I can't figure out where the problem could be. The timer params seem to be alright.
But I have some more questions.
Do you have loops where you're setting the timer?
Does any other function call OnPlayerPayDay?
Do you have another timer that calls this function?
Also try to use 3600000 instead of 3600*1000.

If these advises don't help, then I can't really do anything o help.
You will have to contact ****** about this issue.
Reply
#10

The timer is set only once under OnGameModeInit
Nop, this the only one. I change the name of the function called and the function itself. The same.
Tried changing the time aswell.

Blah, it's impossible to contact him, i'll just wait for him here..




EDIT: timerfix.inc seems to fix the problem. But it is still weird and if someone know why that happened, i'll be happy to hear!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)