SetEntityInvincible
DocsSetEntityInvincible(entity, toggle)Description
Sets a ped or an object totally invincible. It doesn't take any kind of damage. Peds will not ragdoll on explosions and the tazer animation won't apply either.
If you use this for a ped and you want Ragdoll to stay enabled, then do:
*(DWORD *)(pedAddress + 0x188) |= (1 << 9);
Use this if you want to get the invincibility status:
bool IsPedInvincible(Ped ped)
{
auto addr = getScriptHandleBaseAddress(ped);
if (addr)
{
DWORD flag = *(DWORD *)(addr + 0x188);
return ((flag & (1 << 8)) != 0) || ((flag & (1 << 9)) != 0);
}
return false;
}Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | — |
toggle | BOOL | — |
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.