How to make the HealthTimer?? Please? =) - 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 make the HealthTimer?? Please? =) (
/showthread.php?tid=68763)
How to make the HealthTimer?? Please? =) -
introzen - 13.03.2009
Okey... The Subject says it all...
For a timer...
new Float:OldHealth;
public OldHealthCheck(playerid)
{
GetPlayerHealth(playerid,OldHealth);
}
public HealthUpdate(playerid)
{
if( // HP Reduced by 40 on 1MS ) SetPlayerHealth(playerid,0);
}
Re: "if(NewHealth (decreased with 45))" How to make? please? =) -
Norn - 13.03.2009
Quote:
Originally Posted by IntrozeN
Okey... The Subject says it all...
"if(NewHealth (decreased with 45))" How to make? please? =)
|
Can you give a more vivid description please?
Re: "if(NewHealth (decreased with 45))" How to make? please? =) -
introzen - 13.03.2009
Edited^^
Re: How to make the HealthTimer?? Please? =) -
Mauzen - 13.03.2009
You would need a 1ms timer, and this is a server performance killer
Apart from this, you could use something like this in HealthUpdate:
Код:
new CurHealth;
GetPlayerHealth(playerid, CurHealth);
if(CurHealth <= OldHealth[playerid] - 40) ...
You also need an array for the OldHealth, else it will be overwritten for each player:
Код:
new Float:OldHealt[MAX_PLAYERS];
public OldHealthCheck(playerid)
{
GetPlayerHealth(playerid,OldHealth[playerid]);
}
Re: How to make the HealthTimer?? Please? =) -
On_Top_Non_Stop - 13.03.2009
OnPlayerUpdate would be perfect for this rather that a 1MS timer.
Re: How to make the HealthTimer?? Please? =) -
introzen - 13.03.2009
I'll test this now
Re: How to make the HealthTimer?? Please? =) -
introzen - 13.03.2009
It didn't work....
Re: How to make the HealthTimer?? Please? =) -
MenaceX^ - 13.03.2009
Quote:
Originally Posted by On_Top_Non_Stop
OnPlayerUpdate would be perfect for this rather that a 1MS timer.
|
OnPlayerUpdate refreshes itself when a player sends a pack.
Re: How to make the HealthTimer?? Please? =) -
ICECOLDKILLAK8 - 13.03.2009
pawn Код:
// Top of script
new Float:OldHealth[MAX_PLAYERS];
// OnPlayerUpdate/Timer
new Float:NewHealth = GetPlayerHealth(playerid);
if(OldHealth[playerid] != 0)
{
if(NewHealth-OldHealth[playerid] >= 40)
{
SetPlayerHealth(playerid, 0);
}
}
OldHealth[playerid] = GetPlayerHealth(playerid);
// OnPlayerDisconnect
OldHealth[playerid] = 0;
Should work
Re: How to make the HealthTimer?? Please? =) -
Norn - 13.03.2009
Quote:
Originally Posted by JeNkStAX
pawn Код:
// Top of script new Float:OldHealth[MAX_PLAYERS]; // OnPlayerUpdate/Timer new Float:NewHealth = GetPlayerHealth(playerid); if(OldHealth[playerid] != 0) { if(NewHealth-OldHealth[playerid] >= 40) { SetPlayerHealth(playerid, 0); } } OldHealth[playerid] = GetPlayerHealth(playerid); // OnPlayerDisconnect OldHealth[playerid] = 0;
Should work
|
How will it work, you havn't even called the GetPlayerHealth function correctly.