GET_ENTITY_FROM_STATE_BAG_NAME
Returns the entity handle for the specified state bag name. For use with [ADD_STATE_BAG_CHANGE_HANDLER](#\_0x5BA35AAF).
CFX
Signature
lua
GetEntityFromStateBagName(bagName)
-- returns EntityParameters
| Name | Type | Description |
|---|---|---|
| char* | An internal state bag ID from the argument to a state bag change handler. |
Usage
Named call
GetEntityFromStateBagName(bagName)InvokeNative
Citizen.InvokeNative(0x4BDF1867, bagName)js 1
AddStateBagChangeHandler("blockTasks", null, async (bagName, key, value /* boolean */) => {
let entity = GetEntityFromStateBagName(bagName);
// Whoops, we were don't have a valid entity!
if (entity === 0) return;
// We don't want to freeze the entity position if the entity collision hasn't loaded yet
while (!HasCollisionLoadedAroundEntity(entity)) {
// The entity went out of our scope before the collision loaded
if (!DoesEntityExist(entity)) return;
await Delay(250);
}
SetEntityInvincible(entity, value)
FreezeEntityPosition(entity, value)
TaskSetBlockingOfNonTemporaryEvents(entity, value)
})lua 2
AddStateBagChangeHandler("blockTasks", nil, function(bagName, key, value)
local entity = GetEntityFromStateBagName(bagName)
-- Whoops, we don't have a valid entity!
if entity == 0 then return end
-- We don't want to freeze the entity position if the entity collision hasn't loaded yet
while not HasCollisionLoadedAroundEntity(entity) do
-- The entity went out of our scope before the collision loaded
if not DoesEntityExist(entity) then return end
Wait(250)
end
SetEntityInvincible(entity, value)
FreezeEntityPosition(entity, value)
TaskSetBlockingOfNonTemporaryEvents(entity, value)
end)Details
- Hash
- API set
- Source
- cfx
Source: cfx
