Skip to content

feat(extra-natives-five): Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION#3862

Open
Rogui20 wants to merge 3 commits intocitizenfx:masterfrom
Rogui20:scripted-anim-msgpack-wrapper
Open

feat(extra-natives-five): Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION#3862
Rogui20 wants to merge 3 commits intocitizenfx:masterfrom
Rogui20:scripted-anim-msgpack-wrapper

Conversation

@Rogui20
Copy link
Copy Markdown

@Rogui20 Rogui20 commented Mar 11, 2026

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)

@github-actions github-actions Bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Mar 11, 2026
@Rogui20 Rogui20 changed the title Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION and PLAY_ENTI… feat(extra-natives-five) Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION Mar 11, 2026
@Rogui20 Rogui20 changed the title feat(extra-natives-five) Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION feat(extra-natives-five): Add msgpack wrapper support for TASK_SCRIPTED_ANIMATION Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant