RedM Index logoRedM Index
NativesHashesClothesBlipsPropsItem Tool
Sign inGet started

Reference

  • Natives
  • Hashes
  • Clothes
  • Blips
  • Props

Namespace

  1. Reference
  2. Natives
  3. GET_PLAYER_FROM_STATE_BAG_NAME

GET_PLAYER_FROM_STATE_BAG_NAME

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

CFX

Signature

lua
GetPlayerFromStateBagName(bagName)
-- returns int

Parameters

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

Usage

Named call
GetPlayerFromStateBagName(bagName)
InvokeNative
Citizen.InvokeNative(0xA56135E0, bagName)
js 1
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!'`)
})
lua 2
AddStateBagChangeHandler("isDead", nil, function(bagName, key, value) 
    local ply = GetPlayerFromStateBagName(bagName)
    -- The player doesn't exist!
    if ply == 0 then return end
    print("Player: " .. GetPlayerName(ply) .. value and 'died!' or 'is alive!')
end)

Details

Hash
API set
Source
cfx

Source: cfx

On this page

  • Signature
  • Parameters
  • Usage
  • Details