SA-MP Forums Archive
Simple Question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Simple Question (/showthread.php?tid=199853)



Simple Question - DeadAhead - 16.12.2010

Do Timer IDs Start from 0 or From 1?

So i could check if (!TimerVariable)


Re: Simple Question - Ash. - 16.12.2010

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.


Re: Simple Question - Benjo - 16.12.2010

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 ^_^


Re: Simple Question - Retardedwolf - 16.12.2010

1 ( 5 char )


Re: Simple Question - Scenario - 16.12.2010

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


Re: Simple Question - Benjo - 16.12.2010

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.