Heath Timer Bug
#1

Hey guys i created a HealthDecrease system for my Server but i foud a bug. when i revive a player, i want to kill that Timer.. i used
PHP код:
public HealthDecrease(playerid)
{
   if(
GetPVarInt(playerid,"Injured") == 1)
   {
    new 
Float:HP;
    
GetPlayerHealth(playeridHP);
    
SetPlayerHealth(playeridHP-2);
    return 
1;
   }
   return 
0;

for that using
PHP код:
 SetTimerEx("HealthDecrease"150001"i"playerid); 
in OnPlayerDeath. but now i just want that HealthDecrease Timer should end for i person only(whom i will revive).. can you tell me how can i do? thanks
Reply
#2

Save the timerid in a variable
PHP код:
// global
new gHDecTimer[MAX_PLAYERS];
// start
gHDecTimer[playerid] = SetTimerEx("HealthDecrease"150001"i"playerid);
// end
KillTimer(gHDecTimer[playerid]); 
Reply
#3

Quote:

gHDecTimer[playerid] = SetTimerEx("HealthDecrease", 15000, 1, "i", playerid);

i should write this at place where Timer Starts right? ie OnPlayerDeath
Reply
#4

Yes, wherever you want to start the timer

But OnPlayerDeath?, that would mean that the timer starts each time the player dies?
Also how can dead people lose health anyways ?
It is your system you should know how it works

Just be sure to kill the timer before you restart it, would suck if a new timer gets started each time the player dies
1. Dead -> 1 Timer running -> 2. Dead -> 2 Timer running -> ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)