SA-MP Forums Archive
Heath Timer Bug - 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: Heath Timer Bug (/showthread.php?tid=599333)



Heath Timer Bug - GTLS - 24.01.2016

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


Re: Heath Timer Bug - Nero_3D - 24.01.2016

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



Re: Heath Timer Bug - GTLS - 24.01.2016

Quote:

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

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


Re: Heath Timer Bug - Nero_3D - 24.01.2016

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 -> ...