Low Health 20% > Injured.
#1

Hi guys, how do I make if a players have 20% health (or lower) they will perform crack anim?? The injured player will perform this anim...
Quote:

PlayAnimEx(playerid, "CRACK", "crckdeth4", 4.0, 0, 1, 1, 1, 0, 1);

And how do I make a gametextforplayer for a player who is injured saying they are injured?
Sry for my bad english, but I hope you guys understand. I need tips or example script about this..
Reply
#2

You could Set a timer to check every sec if the player's health under 20 and if yes apply the animation you like.

Edit: Use EiresJason's code, It's better.
Reply
#3

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
   
    if(hp <= 20) ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
    return 1;
}
Reply
#4

Quote:
Originally Posted by EiresJason
Посмотреть сообщение
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
   
    if(hp <= 20) ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
    return 1;
}
I'm afraid they'll zombie walk, or shoot, is there any stuff that can disable them from shooting or walking? Only disable, not remove the weapons.

Oh and how do I make it they will be normal (they can walk) after they have more than 20 health?

EDIT: Can I use TogglePlayerControllable to disable them from walking if they have below than 20 health?
Reply
#5

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
   
    if(hp <= 20)
    {
        TogglePlayerControllable (playerid,0);
        ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
        SetTimerEx("MoreThan20HP",1000,true,"i",playerid);
    }
    return 1;
}

forward MoreThan20HP(playerid);
public MoreThan20HP(playerid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);

   if(hp >= 21) TogglePlayerControllable (playerid,1);

}
Reply
#6

TogglePlayerControllable To stop them from moving, I think you can't make them unable to shoot while they have an armed weapon, Either Set the armed weapon to 0 or make him unable to give damage to any other player, And about making them able to move again after they get more they 20 health, You'll need a timer..
Reply
#7

@Elires, use ClearAnimations(playerid);, much better!

SetPlayerControllable is only to "un-freeze" players.
Reply
#8

Quote:
Originally Posted by Sublime
Посмотреть сообщение
@Elires, use ClearAnimations(playerid);, much better!

SetPlayerControllable is only to "un-freeze" players.
I know XD

The thread starter wanted them frozen so they can't move.
Reply
#9

Quote:
Originally Posted by EiresJason
Посмотреть сообщение
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
   
    if(hp <= 20)
    {
        TogglePlayerControllable (playerid,0);
        ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
        SetTimerEx("MoreThan20HP",1000,true,"i",playerid);
    }
    return 1;
}

forward MoreThan20HP(playerid);
public MoreThan20HP(playerid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);

   if(hp >= 21) TogglePlayerControllable (playerid,1);

}
How do I make injured player (below 20 health) keeps decreasing 1% health every 4 seconds?
Reply
#10

Quote:
Originally Posted by EiresJason
Посмотреть сообщение
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
     
   
    if(hp <= 20)
    {
        TogglePlayerControllable (playerid,0);
        ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
        SetTimerEx("MoreThan20HP",1000,true,"i",playerid);
    }
    return 1;
}

forward MoreThan20HP(playerid);
public MoreThan20HP(playerid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);

   if(hp >= 21) TogglePlayerControllable (playerid,1);

}
That needs a slight modification since GetPlayerHealth() will return the HP before the player was damaged.

pawn Код:
new Float:hp;
    GetPlayerHealth(playerid,hp);
    hp -= amount;
There is also problems with the new code you provided, for instance the time is not killed from subsequent OnPlayerTakeDamage() which will cause multiple times to run.

I wouldn't use timers like you are instead I would create a timer which loops through all players instead of making a bunch of individual timers that is very sloppy and messy so you would get something like this.

pawn Код:
new Injured[MAX_PLAYERS];
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(!Injured[playerid])
    {
        new Float:hp;
        GetPlayerHealth(playerid,hp);
        hp -= amount;

        if(hp <= 20)
        {
            TogglePlayerControllable (playerid,0);
            ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
            Injured[playerid] = 1;
        }
    }
    return 1;
}
pawn Код:
public OnGameModeInit()
{
    SetTimer("InjuredTimer", 4000, true);
    return 1;
}
pawn Код:
forward InjuredTimer();
public InjuredTimer()
{
    foreach(new i : Player)
    {
        if(Injured[i])
        {
            new Float:hp;
            GetPlayerHealth(i, hp);

            if(hp <= 20.0) SetPlayerHealth(i, hp-1.0);
            else
            {
                TogglePlayerControllable(i,1);
                Injured[i] = 0;
            }
        }
    }
}
That is how I would do it (Untested but should work )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)