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



Broken Timer - Jack.7331 - 08.04.2012

So I decided to make a timer, where every second, the game checks if your health goes under 20, when it does, you slowly begin to bleedout and have to call the EMS, only problem is, it doesn't work.
pawn Код:
public Dying() {
    foreach(Player, x) {
    if(playerVariables[x][pHealth] <= 20)
    {
    playerVariables[x][pBleedingOut] = 1;
    ApplyAnimation(x, "SWAT", "gnstwall_injurd", 4.0, 1, 0, 0, 0, 0);
    TogglePlayerControllable(x, 0);
    playerVariables[x][pHealth] -= 10;
    }
    }
}
It compiles fine, I just die.

pawn Код:
SetTimer("Dying", 1, true);
^ Under OnPlayerSpawn


Re: Broken Timer - mineralo - 08.04.2012

set timer fine, you did every 1 milisecond
try this/
pawn Код:
SetTimer("Dying", 1000, true);



Re: Broken Timer - Jack.7331 - 08.04.2012

Quote:
Originally Posted by mineralo
Посмотреть сообщение
set timer fine, you did every 1 milisecond
try this/
pawn Код:
SetTimer("Dying", 1000, true);
Woops, I meant every milisecond.


Re: Broken Timer - mineralo - 08.04.2012

try this
pawn Код:
forward Dying();
public Dying()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(playerVariables[i][pHealth] <= 20)
    {
    playerVariables[i][pBleedingOut] = 1;
    ApplyAnimation(i, "SWAT", "gnstwall_injurd", 4.0, 1, 0, 0, 0, 0);
    TogglePlayerControllable(i, 0);
    playerVariables[i][pHealth] -= 10;
    }
}
return 1;
}
now will check every body