How to lose hp every 10 seconds? how to make that?
#1

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

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 :)
}
}
}
Reply
#3

On top of your script under the includes:
pawn Код:
forward hpupdate();
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
Reply
#4

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

Thanks got it working
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)