How to know if a player is dead and do something?

I want to know if a player dead and if he dies do something in my DB ! :slight_smile:
thank you

There’s a playerdied or playerwasted event somewhere. Just search in the server folder “wasted” *.lua or “died”

That code shows you how to check if player died. But I’m fairly sure there’s an event already. Check the obituary folder in the resources that’s not used but I think does something similiar.

local playerPed = GetPlayerPed(-1)
if IsEntityDead(playerPed) then
    --Do something about it
end
1 Like

There are some natives you could use.

GetEntityHealth(GetPlayerPed(clientID)) - Check if the health is a specific value and if so, the player is dead. I think it was 100 for Player.

IsPlayerDead(PlayerId())
IsPedDeadOrDying(GetPlayerPed(clientID), 1)

It’s a client script, isn’t it ?

Natives are always client-side

Okay :wink: thank you ! where did you find the documentation about playerPed and the rest

https://runtime.fivem.net/doc/reference.html

1 Like