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

GET_PLAYER_FROM_STATE_BAG_NAME

0xA56135E0
// GetPlayerFromStateBagName
int GET_PLAYER_FROM_STATE_BAG_NAME(char* bagName);
Parameters:
  • bagName:

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

Returns:

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

On the server this will return the players source, on the client it will return the player handle.

Examples:

  • JavaScript
  • Lua
AddStateBagChangeHandler("isDead", null, async (bagName, key, value /* boolean */) => {
    const ply = GetPlayerFromStateBagName(bagName);
    // The player doesn't exist!
    if (ply === 0) return;
    console.log(`Player: ${GetPlayerName(ply)} ${value ? 'died!' : 'is alive!'`)
})
GET_PED_ARMOUR(Ped ped)
GET_PED_CAUSE_OF_DEATH(Ped ped)
GET_PED_DECORATIONS(Ped ped)
GET_PED_DENSITY_MULTIPLIER()
GET_PED_DESIRED_HEADING(Ped ped)
GET_PED_EYE_COLOR(Ped ped)
GET_PED_FACE_FEATURE(Ped ped, int index)
GET_PED_HAIR_COLOR(Ped ped)
GET_PED_HAIR_HIGHLIGHT_COLOR(Ped ped)
GET_PED_HEAD_OVERLAY_DATA(Ped ped, int index, int* overlayValue, int* colourType, int* firstColour, int* secondColour, float* overlayOpacity)
GET_PED_IN_VEHICLE_SEAT(Vehicle vehicle, int seatIndex)
GET_PED_MAX_HEALTH(Ped ped)
GET_PED_MODEL_PERSONALITY(Hash modelHash)
GET_PED_MOVEMENT_CLIPSET(Ped ped)
GET_PED_SCRIPT_TASK_COMMAND(Ped ped)
GET_PED_SCRIPT_TASK_STAGE(Ped ped)
GET_PED_SOURCE_OF_DAMAGE(Ped ped)
GET_PED_SOURCE_OF_DEATH(Ped ped)
GET_PED_SPECIFIC_TASK_TYPE(Ped ped, int index)
GET_PLAYER_CAMERA_ROTATION(char* playerSrc)
GET_PLAYER_ENDPOINT(char* playerSrc)
GET_PLAYER_FAKE_WANTED_LEVEL(char* playerSrc)
GET_PLAYER_FROM_INDEX(int index)
GET_PLAYER_FROM_SERVER_ID(int serverId)
GET_PLAYER_FROM_STATE_BAG_NAME(char* bagName)
GET_PLAYER_GUID(char* playerSrc)
GET_PLAYER_IDENTIFIER(char* playerSrc, int identifier)
GET_PLAYER_IDENTIFIER_BY_TYPE(char* playerSrc, char* identifierType)
GET_PLAYER_INVINCIBLE(char* playerSrc)
GET_PLAYER_INVINCIBLE_2(Player player)
GET_PLAYER_LAST_MSG(char* playerSrc)
GET_PLAYER_MAX_ARMOUR(char* playerSrc)
GET_PLAYER_MAX_HEALTH(char* playerSrc)
GET_PLAYER_MAX_STAMINA(Player playerId)
GET_PLAYER_MELEE_WEAPON_DAMAGE_MODIFIER(Player playerId)