Health with 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Health with timer (
/showthread.php?tid=110502)
Health with timer -
Mechscape - 26.11.2009
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?
Re: Health with timer -
ExoSanty - 26.11.2009
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
Re: Health with timer -
Mechscape - 26.11.2009
Ok i wait.
Re: Health with timer -
ExoSanty - 26.11.2009
Код:
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]);
Re: Health with timer -
Mechscape - 26.11.2009
Thanks.
Is that works for all players will be taken -5.0 health if 15 minutes over?
// Nvm, worked.