How to lose hp every 10 seconds? how to make that? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to lose hp every 10 seconds? how to make that? (
/showthread.php?tid=103790)
How to lose hp every 10 seconds? how to make that? -
dirkblok - 21.10.2009
Hey,
I have a quit simple question I think..
How to make that every 10 seconds you lose 1 hp?
I thought with a SetTimer? but I don't get it I think
Can someone explain it to me?
Thanks alot
Dirk
Re: How to lose hp every 10 seconds? how to make that? -
pagie1111 - 21.10.2009
pawn Код:
forward HPTimer();//forward goes above OnFilterscriptInit()
SetTimer("HPTimer",10000,1);//interval has to be in milliseconds. and repeating is 1 or true.
public HPTimer()//Timers are run as publics - required to be forwarded
{
for(new i = 0; i <MAX_PLAYERS; i++)//loops through ALL players
{
if(IsPlayerConnected(i))//if they are not connected it will not work for them
{
new Float:HP;//Float for their current HP
GetPlayerHealth(i,HP);//Get their HP and saves it as the HP Float
SetPlayerHP(i,HP - 1.00);//Will minus their HP by 1 every 10 seconds :)
}
}
}
Re: How to lose hp every 10 seconds? how to make that? -
Rzzr - 21.10.2009
On top of your script under the includes:
Under OnGameModeInit
pawn Код:
SetTimer("hpupdate", 10000, true);
Somewhere in your script:
pawn Код:
public hpupdate()
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new Float: health;
GetPlayerHealth(i, health);
SetPlayerHealth(i, health-1);
}
}
}
NOTE: I didn't test this but it should work fine i think
EDIT: Damn you posted it while I was typing it :P
Re: How to lose hp every 10 seconds? how to make that? -
saiberfun - 21.10.2009
ppl u still don'T need to do isplayerconnected
cuz if they arent connecxted they wont get effected anywayz
tho he asked for a timer per person i guess not for every person
so for one person u use
SetTimerEx("Jailer", 1000, true, "i", playerid);
publicname, time, loop?, integer, playerid
Re: How to lose hp every 10 seconds? how to make that? -
dirkblok - 21.10.2009
Thanks
got it working