Health with timer
#1

What about 15 minutes in millisecond's?
15000 ?
Код:
SetTimer("HealthOff", 15000, true);
Is that correct?
Код:
public HealthOff(playerid)
{
	new Float:health;
 	GetPlayerHealth(playerid, health);
 	SetPlayerHealth(playerid, health -5.0);
	return 1;
}
If any 15 minutes then takes -5 health, and more 15 minutes, then taking -5.0....................

Where i do put timer to?.. OnPlayerSpawn? OnPlayerConnect?
Reply
#2

Quote:
Originally Posted by Tundmatu
What about 15 minutes in millisecond's?
15000 ?
Код:
SetTimer("HealthOff", 15000, true);
Is that correct?
Код:
public HealthOff(playerid)
{
	new Float:health;
 	GetPlayerHealth(playerid, health);
 	SetPlayerHealth(playerid, health -5.0);
	return 1;
}
If any 15 minutes then takes -5 health, and more 15 minutes, then taking -5.0....................

Where i do put timer to?.. OnPlayerSpawn? OnPlayerConnect?
15000 milliseconds are 15 seconds
here's 15 minutes:
"HealthOff", 900*1000,

you would best set the timer at onplayerspawn.

but! this wont work cause your 'public HealthOff' doesn't know what playerid is... so this will always be 0

gimme a sec, i'll write you something that would work

Reply
#3

Ok i wait.
Reply
#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
#5

Thanks. Is that works for all players will be taken -5.0 health if 15 minutes over?

// Nvm, worked.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)