Samp onplayertakedamage bodypart accuracy
#1

Hello everyone,

I am creating a realistic damage response on getting shot on body parts.
Example code:
PHP код:
if(issuerid != INVALID_PLAYER_ID && weaponid == 30 && bodypart == 3)
    {
        if (
GetPlayerState(playerid) != PLAYER_STATE_WASTED)
         {
             if(
BodyPart[playerid][Body] >= 5)
             {
                
format(str,sizeof(str),"%s(%i) groans in pain from the bullets that pierced his chest and fell on the ground.",PlayerName(playerid),playerid);
                
SendNearbyMessage(playerid,30.0,str,ORANGE);
                  
ApplyAnimation(playerid"SWEET""Sweet_injuredloop"4.1,1,0,0,0,0,1);
                  
ApplyAnimation(playerid"SWEET""Sweet_injuredloop"4.1,1,0,0,0,0,1);
                  
BodyPart[playerid][Torso] = 1;
                   
BodyPart[playerid][Injured] = 1;
                
SendClientMessage(playerid,LRED,"You are slowly starting to die, you can try to get a medic or accept your death with /acceptdeath");
            }
            else
            {
                
BodyPart[playerid][Body] += 1;
            }
          }
    } 
The problem is that, whenever a player is in an animation, and you shoot the players head when he is using an anim which lays him on the ground will injure his legs instead of head.

Is there any way to fix this?
Reply
#2

I'm not sure how that happens but I recommend you using OnPlayerUpdate for your animation.

You won't have to repeat the anim in OnPlayerTakeDamage and it'll be impossible for the player to get out of the animation or move from their death position.

Example:
Код:
OnPlayerUpdate(playerid)
{
     if(BodyPart[playerid][Injured])
     {
          ApplyAnimation(playerid, "SWEET", "Sweet_injuredloop", 4.1,1,0,0,0,0,1); 
     }
}
Just a thought.
Reply
#3

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
I'm not sure how that happens but I recommend you using OnPlayerUpdate for your animation.

You won't have to repeat the anim in OnPlayerTakeDamage and it'll be impossible for the player to get out of the animation or move from their death position.

Example:
Код:
OnPlayerUpdate(playerid)
{
     if(BodyPart[playerid][Injured])
     {
          ApplyAnimation(playerid, "SWEET", "Sweet_injuredloop", 4.1,1,0,0,0,0,1); 
     }
}
Just a thought.
You misunderstood the question.
I have something to prevent the player leaving the animation/position.
But when the player is on the ground. And you shoot on his head, the script thinks you shoot on his legs.
Reply
#4

It may be an animation bug, not sure if you can fix this... did you try with other animations too?

And probably, I am not sure, the player position that the script will see is "stand up" even when he is doing animations. You can check this by trying to jump ontop of a player that is in a fall or sit anim.
Reply
#5

The animations wont bei fixed dir that i think. It would be to much work.

Just ask if the player is doing an animation. If so, dont call your system.
Reply
#6

I think it can't be done. I will try to disable it when the player is using a anim.
I do have another question actually.
When the player buys armor and equips it, it should be that the bullet will not hit the torso.
I can do this like this(working):
PHP код:
if(Inventory[playerid][KevlarEquip] == 0;
        {
            if (
GetPlayerState(playerid) != PLAYER_STATE_WASTED)
             {
                
format(str,sizeof(str),"%s(%i) groans in pain from the bullet that pierced his chest and fell on the ground.",PlayerName(playerid),playerid);
                
SendNearbyMessage(playerid,30.0,str,ORANGE);
                  
ApplyAnimation(playerid"SWEET""Sweet_injuredloop"4.1,1,0,0,0,0,1);
                  
BodyPart[playerid][Torso] = 1;
                   
BodyPart[playerid][Injured] = 1;
                
SendClientMessage(playerid,LRED,"You are slowly starting to die, you can try to get a medic or accept your death with /acceptdeath");
              }
          } 
But the part which i am stuck at, is on how do i set Inventory[playerid][KevlarEquip] to 0 when the player's armor has been gone? not by unequiping it, but by getting shot. Is there a way to getplayerarmour or something?
Reply
#7

OnPlayerTakeDamage, check if his armor is 0, if yes then set the variable to 0
Reply
#8

That will result in getting shot the second time the bullet hits the torso, when the player still does have armor.
I need it to be different for every single weapon based on the players armor which is set by equipping the kevlar using this: SetPlayerArmourEx(playerid,100);.
Код:
stock SetPlayerArmourEx(playerid,Float:AP)
{
 	if(AP>99.0)AP=99.0;
	Armor[playerid]=AP;
	return SetPlayerArmour(playerid,AP);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)