Can't figure it out
#1

Код:
public Health(playerid)
{
  new Float:health;
  if(GetPlayerHealth(playerid, health) < 40)
  {
    ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
  	SendClientMessage(playerid, COLOR_RED, "You have been wounded, you need a paramedic !");
  	return 1;
  }
  return 1;
}
It complies fine, but when I test it IG when I get down to 40% health and less it don't do anim.
Reply
#2

Errr, is it in a timer? It won't just work on its own accord..
Reply
#3

Yes and it should be
pawn Код:
GetPlayerHealth(playerid, health);
if(health < 40.0)
Reply
#4

Quote:
Originally Posted by Weirdosport
Errr, is it in a timer? It won't just work on its own accord..
What is the timer for?
I mean like how would a timer know when my health is 40%?
Sorry this is my first time scripting something like this.
Reply
#5

The timer is for to execute this public every x seconds.

But to avoid it, you can put this code in the public OnPlayerUpdate. It's called everytime a player moves
Reply
#6

That public will only be trigger when you tell it to. Alone in a script it will do nothing. Also as Orb said GetPlayerHealth does not return the health, but saves it to the Float you choose.

You need something like this:

pawn Код:
new Float:health;
forward Health();

public OnFilterScriptInit()
{
  SetTimer("Health", 1000, 1);
  return 1;
}

public Health()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(playerid))
    {
      GetPlayerHealth(i, health)
      if(health < 40)
      {
        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
        SendClientMessage(playerid, COLOR_RED, "You have been wounded, you need a paramedic !")
      }
    }
  }
  return 1;
}
Unsure as to whether this would be better in OnPlayerUpdate.. OnPlayerUpdate is called quite a lot, so it really depends on how many people on your server I s'pose.
Reply
#7

Quote:
Originally Posted by Weirdosport
That public will only be trigger when you tell it to. Alone in a script it will do nothing. Also as Orb said GetPlayerHealth does not return the health, but saves it to the Float you choose.

You need something like this:

pawn Код:
new Float:health;
forward Health();

public OnFilterScriptInit()
{
  SetTimer("Health", 1000, 1);
  return 1;
}

public Health()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(playerid))
    {
      GetPlayerHealth(i, health)
      if(health < 40)
      {
        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
        SendClientMessage(playerid, COLOR_RED, "You have been wounded, you need a paramedic !")
      }
    }
  }
  return 1;
}
Unsure as to whether this would be better in OnPlayerUpdate.. OnPlayerUpdate is called quite a lot, so it really depends on how many people on your server I s'pose.
Код:
C:\Documents and Settings\Leo\Desktop\LS-RP backup\LSRP.pwn(2624) : error 017: undefined symbol "playerid"
C:\Documents and Settings\Leo\Desktop\LS-RP backup\LSRP.pwn(2628) : error 001: expected token: ";", but found "if"
C:\Documents and Settings\Leo\Desktop\LS-RP backup\LSRP.pwn(2630) : error 017: undefined symbol "playerid"
C:\Documents and Settings\Leo\Desktop\LS-RP backup\LSRP.pwn(2631) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

pawn Код:
forward Health();

public OnFilterScriptInit()
{
  SetTimer("Health", 1000, 1);
  return 1;
}

public Health()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      new Float:health;
      GetPlayerHealth(i, health);
      if(health < 40)
      {
        ApplyAnimation(i, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
        SendClientMessage(i, COLOR_RED, "You have been wounded, you need a paramedic !");
      }
    }
  }
  return 1;
}
Try that.
Reply
#9

Quote:
Originally Posted by Gappy
pawn Код:
forward Health();

public OnFilterScriptInit()
{
  SetTimer("Health", 1000, 1);
  return 1;
}

public Health()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      new Float:health;
      GetPlayerHealth(i, health);
      if(health < 40)
      {
        ApplyAnimation(i, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
        SendClientMessage(i, COLOR_RED, "You have been wounded, you need a paramedic !");
      }
    }
  }
  return 1;
}
Try that.
It complies fine, but when I get down to 40 HP it doesn't do Animation
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)