--  LUA  AddStateBagChangeHandler  0x5BA35AAF  -- ADD_STATE_BAG_CHANGE_HANDLER
local retval --[[ integer ]] =
	AddStateBagChangeHandler(
		keyFilter --[[ string ]], 
		bagFilter --[[ string ]], 
		handler --[[ func ]]
	)

Parameters:

    keyFilter:

    The key to check for, or null for no filter.
    bagFilter:

    The bag ID to check for such as entity:65535, or null for no filter.
    handler:

    The handler function.

Returns:

A cookie to remove the change handler.

Adds a handler for changes to a state bag.

The function called expects to match the following signature:
 
function StateBagChangeHandler(bagName: string, key: string, value: any, reserved: number, replicated: boolean);
 bagName: The internal bag ID for the state bag which changed. This is usually player:Source, entity:NetID or localEntity:Handle.
 key: The changed key.
 value: The new value stored at key. The old value is still stored in the state bag at the time this callback executes.
 reserved: Currently unused.
 replicated: Whether the set is meant to be replicated.

At this time, the change handler can't opt to reject changes.

If bagName refers to an entity, use GET_ENTITY_FROM_STATE_BAG_NAME to get the entity handle If bagName refers to a player, use GET_PLAYER_FROM_STATE_BAG_NAME to get the player handle

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?

1
AddStateBagChangeHandler - Native

Do you understand the native?

You will be redirected

Related Examples and Posts

By MK