FiveM Docs / Native Reference
API Set:
  • all
  • server
  • client
Language:
  • raw
  • lua
  • c#
  • js
Namespace: CFXAPI set: sharededitImprove

GET_ENTITY_FROM_STATE_BAG_NAME

0x4BDF1867
// GetEntityFromStateBagName
Entity GET_ENTITY_FROM_STATE_BAG_NAME(char* bagName);
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", 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)
})
Privacy
•
Cookie Policy
•
Cookie Settings
GET_ALL_VEHICLES()
GET_AMBIENT_PED_RANGE_MULTIPLIER()
GET_AMBIENT_VEHICLE_RANGE_MULTIPLIER()
GET_CALMING_QUAD_AT_COORDS(float x, float y)
GET_CALMING_QUAD_BOUNDS(int waterQuad, int* minX, int* minY, int* maxX, int* maxY)
GET_CALMING_QUAD_COUNT()
GET_CALMING_QUAD_DAMPENING(int waterQuad, float* calmingQuadDampening)
GET_CAM_MATRIX(Cam camera, Vector3* rightVector, Vector3* forwardVector, Vector3* upVector, Vector3* position)
GET_CLOSEST_TRACK_NODES(Vector3 position, float radius)
GET_CONSOLE_BUFFER()
GET_CONVAR(char* varName, char* default_)
GET_CONVAR_BOOL(char* varName, BOOL defaultValue)
GET_CONVAR_FLOAT(char* varName, float defaultValue)
GET_CONVAR_INT(char* varName, int default_)
GET_CURRENT_GAME_NAME()
GET_CURRENT_PED_WEAPON(Ped ped)
GET_CURRENT_RESOURCE_NAME()
GET_CURRENT_SERVER_ENDPOINT()
GET_DUI_HANDLE(long duiObject)
GET_ENTITY_ADDRESS(Entity entity)
GET_ENTITY_ARCHETYPE_NAME(Entity entity)
GET_ENTITY_ATTACHED_TO(Entity entity)
GET_ENTITY_COLLISION_DISABLED(Entity entity)
GET_ENTITY_COORDS(Entity entity)
GET_ENTITY_FROM_STATE_BAG_NAME(char* bagName)
GET_ENTITY_HEADING(Entity entity)
GET_ENTITY_HEALTH(Entity entity)
GET_ENTITY_INDEX_FROM_MAPDATA(int mapdata, int entity)
GET_ENTITY_MAPDATA_OWNER(Entity entity, int* mapdataHandle, int* entityHandle)
GET_ENTITY_MAX_HEALTH(Entity entity)
GET_ENTITY_MODEL(Entity entity)
GET_ENTITY_ORPHAN_MODE(Entity entity)
GET_ENTITY_POPULATION_TYPE(Entity entity)
GET_ENTITY_ROTATION(Entity entity)
GET_ENTITY_ROTATION_VELOCITY(Entity entity)