citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.48k stars 2.06k forks source link

`TaskPlayAnim` Server RPC native not working with specific animation/s #2236

Open cm8263 opened 11 months ago

cm8263 commented 11 months ago

Nothing appears to happen when attempting to use the TaskPlayAnim Server RPC with the animation dictionary mp_cop_armoury. The exact same native and parameters work on the client without issue.

Minimal Repo:

Client

This works

public Main()
{
    API.RequestAnimDict("mp_cop_armoury");
}

[Command("testcommand")]
internal void OnTestCommand()
{
    Ped ped = Game.PlayerPed;

    API.TaskPlayAnim(ped.Handle, "mp_cop_armoury", "rifle_on_counter_cop", 8f, -8f, -1, 0, 0f, false, false, false);
}

Server

This does not work

// Still executing `RequestAnimDict` on the client

[Command("testcommand")]
internal void OnTestCommand()
{
    Ped ped = Players.First().Character;

    API.TaskPlayAnim(ped.Handle, "mp_cop_armoury", "rifle_on_counter_cop", 8f, -8f, -1, 0, 0f, false, false, false);
}

@NexxonOfficial and myself spent over an hour (include an extra hour by myself) trying different combinations of parameters to try and get it to work, with no luck. The same code can be used to play other animations, just no the one listed above.

gottfriedleibniz commented 11 months ago

How strings are stored then referenced is a bit rough (e.g., vector reallocation invalidating previous pointers).

A quick-and-dirty solution (read: hack; YMMV) could be to reserve/preallocate based on GetArguments().

cm8263 commented 11 months ago

Thanks for your response.

A quick-and-dirty solution (read: hack; YMMV) could be to reserve/preallocate based on GetArguments().

Do you mind expanding on this a bit for me? Thanks.

BugCode1 commented 7 months ago

This problem also occurs for the native "TaskPlayAnimAdvanced"