Does if(TIMER_RUNNING[playerid]) detect if a timer is running? - 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)
+--- Thread: Does if(TIMER_RUNNING[playerid]) detect if a timer is running? (
/showthread.php?tid=592812)
Does if(TIMER_RUNNING[playerid]) detect if a timer is running? -
rangerxxll - 30.10.2015
I've been really curious to see if this is an efficient way to see if a timer is active, or not. Because I'm using it under OnPlayerGiveDamage and it works fine for killing variables. However, when I used it for a splint system (I was detecting if the bandage timer was running, that way the player couldn't use a splint) it didn't work for detecting that.
Example:
pawn Код:
if(TIMER_BANDAGE[playerid])
{
SCM(pid,COLOR, "You can't use this with the bandage timer running");
return 1;
}
^ This code does not work, however:
pawn Код:
if(TIMER_FISH[damagedid] || TIMER_PICKUPLOOT[damagedid] || TIMER_COOKING[damagedid] || TIMER_FIRE[damagedid]
Seems to work fine.
Re: Does if(TIMER_RUNNING[playerid]) detect if a timer is running? -
PrO.GameR - 30.10.2015
There is no IsTimerValid or sth like that, therefore you need to reset your timer variables to -1 ( since 0 can also be used as a timer. ), and check to see if they are -1
Re: Does if(TIMER_RUNNING[playerid]) detect if a timer is running? -
Kevln - 30.10.2015
Quote:
Originally Posted by PrO.GameR
There is no IsTimerValid or sth like that, therefore you need to reset your timer variables to -1 ( since 0 can also be used as a timer. ), and check to see if they are -1
|
Timer IDs start at 1, the wiki is wrong.
Re: Does if(TIMER_RUNNING[playerid]) detect if a timer is running? -
AbyssMorgan - 30.10.2015
PHP код:
if(timerid > 0) //timer called, it is not known whether the active
PHP код:
if(TIMER_BANDAGE[playerid] > 0) //timer called, it is not known whether the active
PHP код:
new bool:YouTimerActive = false;
public YouTimerFunction(){
YouTimerActive = true;
//code
YouTimerActive = false;
//repeat
return 1;
}
if(YouTimerActive){
//timer executed
}