Jump to content
WillUnderscore

Checking if Ped is dead

Recommended Posts

I'm currently writing a plugin, and as part of my main logic, I want to check to see whether a Ped is dead or not. I'm running the below if statement.

if(ped.IsDead)

However, this seems to return true, even when I've shot this particular Ped in the head a few times. I've also noticed that when running the following function, I'm getting values around 150 to 200 (at which point the Ped seems to stop being a Ped (they become undetectable), and start being an entity?

Game.LogTrivial("Ped health: " + ped.Health.ToString());

I presume that the Rage IsDead function shares/is based on the native PED::IS_PED_DEAD_OR_DYING

 

What I'm asking: How can I reliably check to see whether a Ped is dying?

Share this post


Link to post
Share on other sites
On 11/21/2018 at 12:54 PM, WillUnderscore said:

I'm currently writing a plugin, and as part of my main logic, I want to check to see whether a Ped is dead or not. I'm running the below if statement.


if(ped.IsDead)

However, this seems to return true, even when I've shot this particular Ped in the head a few times. I've also noticed that when running the following function, I'm getting values around 150 to 200 (at which point the Ped seems to stop being a Ped (they become undetectable), and start being an entity?


Game.LogTrivial("Ped health: " + ped.Health.ToString());

I presume that the Rage IsDead function shares/is based on the native PED::IS_PED_DEAD_OR_DYING

 

What I'm asking: How can I reliably check to see whether a Ped is dying?

 

of course, if you shot the ped in the head a few times, the Ped.isDead will return true, which mean the ped is totally dead. Nothing wrong with it. 🙂

what do you mean with "dying"? do you mean the ped is still alive but badly injured?

from my experience, when the ped is already lying down in ragdoll state, that would always mean that the ped's isDead=true;

 

FYI. when isDead=true, you cannot ask the ped to play certain animation task. you have to do some workaround to make the dead ped playing animation.

Edited by Pazzi

Share this post


Link to post
Share on other sites
On 11/21/2018 at 10:54 PM, WillUnderscore said:

I'm currently writing a plugin, and as part of my main logic, I want to check to see whether a Ped is dead or not. I'm running the below if statement.


if(ped.IsDead)

However, this seems to return true, even when I've shot this particular Ped in the head a few times. I've also noticed that when running the following function, I'm getting values around 150 to 200 (at which point the Ped seems to stop being a Ped (they become undetectable), and start being an entity?


Game.LogTrivial("Ped health: " + ped.Health.ToString());

I presume that the Rage IsDead function shares/is based on the native PED::IS_PED_DEAD_OR_DYING

 

What I'm asking: How can I reliably check to see whether a Ped is dying?

There are many ways around this.

1. One way of checking if your target is dead would be to invoke IS_PED_RAGDOLL and invoke it again after a certain period of time or keep checking if the ped is ragdolling to confirm that the ped is, infact, dead. This is a pretty bad solution if you're looking to check if the ped is dead on the spot.

 

2. You could check if the target's health is below 200 and then decide if the target is dead or not from there. In my opinion this would be your best choice.

 

3. If the target does infact go from a ped to an entity when below a certain amount of health, you could utilize IS_ENTITY_DEAD.

Edited by doubledecker

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×