--  LUA  GetEntityFromStateBagName

0x4BDF1867

-- GET_ENTITY_FROM_STATE_BAG_NAME
local retval --[[ Entity ]] =
	GetEntityFromStateBagName(
		bagName --[[ string ]]
	)

Parameters:

    bagName:

    An internal state bag ID from the argument to a state bag change handler.

Returns:

The entity handle or 0 if the state bag name did not refer to an entity, or the entity does not exist.

Returns the entity handle for the specified state bag name. For use with ADD_STATE_BAG_CHANGE_HANDLER.

Examples:

    JavaScript
    Lua

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)
 
 

Parameters:

header:

sentence.

header:

sentence.

header:

sentence.

Returns:

sentence.

Summary

sentence.

Example

---  
    


Additional natives used in this example, or natives commonly used with this native.

NATIVE, NATIVE

Common Errors or Problems

Problem: sentence.

Problem: sentence.

Problem: sentence.

Credits and Disclaimers

The base of this data was taken from the redm/cfx fivem/rdr docs, and vespura. We have been saving and making notes for two years now, and are now adding them to our site for everyone to use. We will be modifying the notes as needed, and building tutorials around the data so these pages will change as we work on it. This is a manual process, not an automated one, so updates will occur as we have time, the priority is releasing resources. Thanks for your patience.

Was the documentation useful?

Related Examples and Posts

Dragon Codes