Health with timer
#4

Код:
at top of script:

forward HealthOff(playerid);
we use settimerex instead because we would want to give along the playerid...
so on player spawn we will set the timer:

Код:
SetTimerEx("HealthOff", 900*1000, 1,"i",playerid);
and the public the timer calls, looks good:

Код:
public HealthOff(playerid)
{
	new Float:health;
 	GetPlayerHealth(playerid, health);
 	SetPlayerHealth(playerid, health -5.0);
	return 1;
}
You might want to be able to disable this for a certain player AND per player:

so at top of script:

Код:
new HealthTimer[MAX_PLAYERS]; //we will be saving the timer to an array so we know wich one to disable
forward HealthOff(playerid);
now on player spawn we will set the timer again but with HealthTimer[playerid]:

Код:
HealthTimer[playerid] = SetTimerEx("HealthOff", 900*1000, 1,"i",playerid);
and the public the timer calls, ok:

Код:
public HealthOff(playerid)
{
	new Float:health;
 	GetPlayerHealth(playerid, health);
 	SetPlayerHealth(playerid, health -5.0);
	return 1;
}
now you can disable a timer for a certain player like (if playerid is defined):

Код:
KillTimer(HealthTimer[playerid]);
Reply


Messages In This Thread
Health with timer - by Mechscape - 26.11.2009, 22:04
Re: Health with timer - by ExoSanty - 26.11.2009, 22:16
Re: Health with timer - by Mechscape - 26.11.2009, 22:38
Re: Health with timer - by ExoSanty - 26.11.2009, 22:46
Re: Health with timer - by Mechscape - 26.11.2009, 22:56

Forum Jump:


Users browsing this thread: 1 Guest(s)