Problem with timers.. -
dundolina - 12.04.2015
Hello i have problem with timers. I have this
Код:
//=============================[Timers]=========================================
SetTimer("UpdateMoney", 1000, 1);
SetTimer("AntiHackCheat", 100, 1);
SetTimer("GeneralTimer", 1000, 1);
SetTimer("CheckPlayers", 10000, 1);
SetTimer("TipBot", 180000, 1);
SetTimer("GameBot", 600000, 1);
return 1;
}
And they just dont work, i mean the tipbot ( message like advert ) and the gamebot ( lottery ) messages comes about 10 minutes later and they come both. Or i see the tip messeges comes 3 at one time with no timer. It seems they dont have timers but i add them and i dont have problems. How to fix this big problem, guys?
Re: Problem with timers.. -
HazardouS - 12.04.2015
Firstly, why do you have two timers with the same repeating interval? Makes no sense.
This is how a timer should look like:
pawn Код:
//somewhere in the gamemode, outside any other callback
forward MyFunction();
public MyFunction()
{
//code goes here
}
//usually under OnGameModeInit
SetTimer("MyFunction", 1000, 1);
This will make MyFunction repeat every 1 second. Now, all you have to do is write some code in the function and you're done. Of course, if you write the code wrongly, it will give unexpected results. Also you should take into account that SA:MP timers have a slight delay, which may get worse if you execute too many operations per second (see "AntiHackCheat" which is repeated 10 times per second).
This said, the rest of the code should be pretty easy to write, unless you're thinking at some sophisticated systems.
Re: Problem with timers.. -
dundolina - 12.04.2015
Yeah my codes it's like your example. One of my timers:
Код:
SetTimer("GameBot", 600000, 1);
Код:
public GameBot()
{
new game = RandomEx(0, 1);
switch (game)
{
case 0:
{
SendClientMessageToAll(COLOR_WHITE, "{FF00FF}Lotto: Лотарята стартира след 20 секунди, напиши {99ff00}/lotto [1-60] {FF00FF},за да си закупиш билет.");
SetTimer("StartLotto", 20000, 0);
}
}
return 1;
}
Re: Problem with timers.. -
Threshold - 12.04.2015
Quote:
Firstly, why do you have two timers with the same repeating interval? Makes no sense.
|
Why does it make no sense
Why would you bundle all the timers with the same interval together in one?
What if you had 2 timers and you combined them into a 3rd timer. Now at some point you want to kill the first timer, so how do you do that without killing the second one? You use separate timers.
pawn Код:
SetTimer("TipBot", 180000, 1);
SetTimer("GameBot", 600000, 1);
180000 = 180 seconds = 3 minutes
600000 = 600 seconds = 10 minutes
So what's the problem again?
Re: Problem with timers.. -
dundolina - 13.04.2015
I think the problem it's not in the timers. I add other message timer different from this i post and i have the same problem. On 1 time gives me 3 messages and lottery messages. This is the problem.
Re: Problem with timers.. -
Camorra - 13.04.2015
Put msg in each public u using in timer, see what's wrong and where like that.