Simple Question
#1

Do Timer IDs Start from 0 or From 1?

So i could check if (!TimerVariable)
Reply
#2

Timer ID's dont specifically start anywhere, they are what you have named them...

pawn Код:
new Timer;
public OnPlayerConnect(playerid)
{
     Timer = SetTimer...
}
Your timer is then set timer - if you want to see what it corresponds to just print timer.
Reply
#3

He means the timerid. I'm pretty sure it starts at 1 so you will be able to check if the timer is running using if(!timer), but I'd do a quick test command on a blank script to doublecheck if I were you:

pawn Код:
new t = SetTimer("RandomMethod", 999999, 0);
new msg[128]; format(msg, sizeof(msg), "timerid: %i", t);
SendClientMessageToAll(-1, msg);
Obviously make sure that there are no other timers in the script ^_^
Reply
#4

1 ( 5 char )
Reply
#5

I don't believe timers have "ID"'s. It's what you define them as. For example: Timer1
Reply
#6

Timers do indeed have IDs, hence being able to set them to a variable. Using the function SetTimer or SetTimerEx returns the ID of the timer as an integer. As an example:

pawn Код:
CMD:timeridtest(playerid, params[])
{
    new msg[128];

    new t1 = SetTimer("RandomMethod", 999999, 0);
    format(msg, sizeof(msg), "t1 timerid: %i", t1);
    printf(msg);

    new t2 = SetTimer("RandomMethod", 999999, 0);
    format(msg, sizeof(msg), "t2 timerid: %i", t2);
    printf(msg);

    new t3 = SetTimer("RandomMethod", 999999, 0);
    format(msg, sizeof(msg), "t3 timerid: %i", t3);
    printf(msg);

    return 1;
}
That would print:
Код:
t1 timerid: 1
t2 timerid: 2
t3 timerid: 3
This also confirms my original answer to the original post: it definitely starts at 1, so if(!timer) can be used.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)