SetEntityHealth
DocsSetEntityHealth(entity, health)Description
When setting health for a player ped, the game will clamp the health value to ensure it does not exceed the maximum health. This maximum health can be retrieved by calling <code>GET_PED_MAX_HEALTH</code>. It can also be modified by calling <code>SET_PED_MAX_HEALTH</code>.
When setting the health for non-player peds or entities, the maximum health will be increased if the new health value exceeds the current maximum.
Default health for male peds is 200, for female peds it is 175.
### Added parameters
- inflictor: The handle for the entity that caused the damage.
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | The entity handle. |
health | int | The health we should set this entity to. |
Quick Snippet: Get Entityentity
entityUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endReturns
voidThis native does not return a value.