feat(extra-natives-five): Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION#3862
Open
Rogui20 wants to merge 3 commits intocitizenfx:masterfrom
Open
feat(extra-natives-five): Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION#3862Rogui20 wants to merge 3 commits intocitizenfx:masterfrom
Rogui20 wants to merge 3 commits intocitizenfx:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal of this PR
This PR allows TASK_SCRIPTED_ANIMATION and PLAY_ENTITY_SCRIPTED_ANIM natives to accept msgpack objects from scripting runtimes (Lua/JS/C#) and convert them into the ScriptInitSlotData structure expected by the game.
This enables scripts to configure scripted animation slots using structured data rather than requiring native-side struct construction.
How is this PR achieving the goal
This PR registers lightweight wrappers for the following natives:
TASK_SCRIPTED_ANIMATION
PLAY_ENTITY_SCRIPTED_ANIM
The wrappers:
Read the msgpack object (fx::scrObject) passed from the scripting runtime.
Deserialize it into a std::map<std::string, msgpack::object>.
Populate a ScriptInitSlotData struct matching the exact layout expected by the native.
Update internal string pointers after construction to ensure valid lifetime.
Replace the arguments in the ScriptContext with pointers to the generated structs.
Forward the call to the original native handler.
Invalid, empty, or malformed msgpack objects automatically fall back to a default empty slot using FillDefaultScriptInitSlotData, allowing scripts to omit unused animation slots safely.
The native behavior itself remains unchanged; this PR only adds argument translation.
This PR applies to the following area(s)
Natives
ScRT: Lua
ScRT: JS
ScRT: C#
Successfully tested on
Game builds: Latest FiveM build (tested on local compiled client)
Platforms: Windows
Checklist
[x] Code compiles and has been tested successfully.
[x] Code explains itself well and/or is documented.
[x] My commit message explains what the changes do and what they are for.
[x] No extra compilation warnings are added by these changes.
Fixes issues
None. This PR adds scripting support for existing natives.
Lua usage:
local anim = msgpack.pack({
state = 1,
dict0 = "clip@csgo",
clip0 = "aim_blend_05",
rate0 = 1.0,
weight0 = 1.0
})
Citizen.InvokeNative(0x126EF75F1E17ABE5, ped, anim, "", "", 0.1, 0.1)