{"hash":"0x4BDF1867","ns":"CFX","name":"GET_ENTITY_FROM_STATE_BAG_NAME","slug":"GET_ENTITY_FROM_STATE_BAG_NAME","official":true,"named":true,"luaName":"GetEntityFromStateBagName","game":"cfx","apiset":"shared","returnType":"Entity","params":[{"name":"bagName","type":"char*","description":"An internal state bag ID from the argument to a state bag change handler."}],"returnsDescription":"The entity handle or 0 if the state bag name did not refer to an entity, or the entity does not exist.","summary":"Returns the entity handle for the specified state bag name.","descriptions":[{"source":"cfx","format":"md","body":"Returns the entity handle for the specified state bag name. For use with [ADD_STATE_BAG_CHANGE_HANDLER](#\\_0x5BA35AAF)."}],"examples":[{"lang":"js","code":"AddStateBagChangeHandler(\"blockTasks\", null, async (bagName, key, value /* boolean */) => {\n    let entity = GetEntityFromStateBagName(bagName);\n    // Whoops, we were don't have a valid entity!\n    if (entity === 0) return;\n    // We don't want to freeze the entity position if the entity collision hasn't loaded yet\n    while (!HasCollisionLoadedAroundEntity(entity)) {\n        // The entity went out of our scope before the collision loaded\n        if (!DoesEntityExist(entity)) return;\n        await Delay(250);\n    }\n    SetEntityInvincible(entity, value)\n    FreezeEntityPosition(entity, value)\n    TaskSetBlockingOfNonTemporaryEvents(entity, value)\n})","source":"cfx"},{"lang":"lua","code":"AddStateBagChangeHandler(\"blockTasks\", nil, function(bagName, key, value) \n    local entity = GetEntityFromStateBagName(bagName)\n    -- Whoops, we don't have a valid entity!\n    if entity == 0 then return end\n    -- We don't want to freeze the entity position if the entity collision hasn't loaded yet\n    while not HasCollisionLoadedAroundEntity(entity) do\n        -- The entity went out of our scope before the collision loaded\n        if not DoesEntityExist(entity) then return end\n        Wait(250)\n    end\n    SetEntityInvincible(entity, value)\n    FreezeEntityPosition(entity, value)\n    TaskSetBlockingOfNonTemporaryEvents(entity, value)\nend)","source":"cfx"}],"aliases":[],"enums":[],"related":[],"sources":["cfx"],"doc":3,"url":"https://natives.borderlinerp.com/natives/CFX/GET_ENTITY_FROM_STATE_BAG_NAME","markdownUrl":"https://natives.borderlinerp.com/natives/CFX/GET_ENTITY_FROM_STATE_BAG_NAME.md","snippets":{"lua":"local retval = GetEntityFromStateBagName(bagName)","luaInvoke":"local retval = Citizen.InvokeNative(0x4bdf1867, bagName, Citizen.ResultAsInteger())","js":"const retval = GetEntityFromStateBagName(bagName);","jsInvoke":"const retval = Citizen.invokeNative('0x4bdf1867', bagName, Citizen.returnResultAnyway(), Citizen.resultAsInteger());","csharp":"int retval = Function.Call<int>((Hash)0x4bdf1867, bagName);","notes":[]}}