How to make the HealthTimer?? Please? =)
#1

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);
}
Reply
#2

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?
Reply
#3

Edited^^
Reply
#4

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]);
}
Reply
#5

OnPlayerUpdate would be perfect for this rather that a 1MS timer.
Reply
#6

I'll test this now
Reply
#7

It didn't work....
Reply
#8

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.
Reply
#9

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)