Does if(TIMER_RUNNING[playerid]) detect if a timer is running?
#1

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.
Reply
#2

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
Reply
#3

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.
Reply
#4

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

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)