@@ -101,6 +101,28 @@ function GetResourceState(resourceName) end
101101function GetVehicleHandbrake (vehicle ) end
102102
103103
104+ --- Returns the entity handle for the specified state bag name. For use with [ADD_STATE_BAG_CHANGE_HANDLER](?\_0x5BA35AAF).
105+ --- @usage AddStateBagChangeHandler("blockTasks", nil, function(bagName, key, value)
106+ --- local entity = GetEntityFromStateBagName(bagName)
107+ --- -- Whoops, we don't have a valid entity!
108+ --- if entity === 0 then return end
109+ --- -- We don't want to freeze the entity position if the entity collision hasn't loaded yet
110+ --- while not HasCollisionLoadedAroundEntity(entity) do
111+ --- -- The entity went out of our scope before the collision loaded
112+ --- if not DoesEntityExist(entity) then return end
113+ --- Wait(250)
114+ --- end
115+ --- SetEntityInvincible(entity, value)
116+ --- FreezeEntityPosition(entity, value)
117+ --- TaskSetBlockingOfNonTemporaryEvents(entity, value)
118+ --- end
119+ --- @hash [0x4BDF1867](https://docs.fivem.net/natives/?_0x4BDF1867)
120+ --- @param bagName string (char* )
121+ --- @return Entity
122+ --- @overload fun ( bagName : string ): Entity
123+ function GetEntityFromStateBagName (bagName ) end
124+
125+
104126--- GetInvokingResource
105127---
106128--- @hash [0x4D52FE5B](https://docs.fivem.net/natives/?_0x4D52FE5B)
@@ -177,7 +199,23 @@ function WasEventCanceled() end
177199--- * **replicated**: Whether the set is meant to be replicated.
178200---
179201--- At this time, the change handler can't opt to reject changes.
180- ---
202+ ---
203+ --- If bagName refers to an entity, use [GET_ENTITY_FROM_STATE_BAG_NAME](?\_0x4BDF1868) to get the entity handle
204+ --- If bagName refers to a player, use [GET_PLAYER_FROM_STATE_BAG_NAME](?\_0xA56135E0) to get the player handle
205+ --- @usage AddStateBagChangeHandler("blockTasks", nil, function(bagName, key, value)
206+ --- local entity = GetEntityFromStateBagName(bagName)
207+ --- -- Whoops, we don't have a valid entity!
208+ --- if entity === 0 then return end
209+ --- -- We don't want to freeze the entity position if the entity collision hasn't loaded yet
210+ --- while not HasCollisionLoadedAroundEntity(entity) do
211+ --- -- The entity went out of our scope before the collision loaded
212+ --- if not DoesEntityExist(entity) then return end
213+ --- Wait(250)
214+ --- end
215+ --- SetEntityInvincible(entity, value)
216+ --- FreezeEntityPosition(entity, value)
217+ --- TaskSetBlockingOfNonTemporaryEvents(entity, value)
218+ --- end
181219--- @hash [0x5BA35AAF](https://docs.fivem.net/natives/?_0x5BA35AAF)
182220--- @param keyFilter string (char* )
183221--- @param bagFilter string (char* )
@@ -423,6 +461,20 @@ function SetResourceKvpFloat(key, value) end
423461function GetInstanceId () end
424462
425463
464+ --- On the server this will return the players source, on the client it will return the player handle.
465+ --- @usage AddStateBagChangeHandler("isDead", nil, function(bagName, key, value)
466+ --- local ply = GetPlayerFromStateBagName(bagName)
467+ --- -- The player doesn't exist!
468+ --- if ply == 0 then return end
469+ --- print("Player: " .. GetPlayerName(ply) .. value and 'died!' or 'is alive!')
470+ --- end
471+ --- @hash [0xA56135E0](https://docs.fivem.net/natives/?_0xA56135E0)
472+ --- @param bagName string (char* )
473+ --- @return number
474+ --- @overload fun ( bagName : string ): number
475+ function GetPlayerFromStateBagName (bagName ) end
476+
477+
426478--- EndFindKvp
427479---
428480--- @hash [0xB3210203](https://docs.fivem.net/natives/?_0xB3210203)
0 commit comments