fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Native TaskPlayAnim does not work with numbers, only "floats"

Open KooperNinja opened this issue 11 months ago • 3 comments

What happened?

Example (Anim dict is already loaded):

--Does not work
TaskPlayAnim(PlayerPedId(), "anim@move_m@prisoner_cuffed", "idle", 8, 8, -1, 57, 1, false, false, false)

--This will work
TaskPlayAnim(PlayerPedId(), "anim@move_m@prisoner_cuffed", "idle", 8.0, 8.0, -1, 57, 1.0, false, false, false)

Expected result

Should work with numbers aswell

Reproduction steps

RequestAnimDict("anim@move_m@prisoner_cuffed")
while not HasAnimDictLoaded("anim@move_m@prisoner_cuffed") do
        Citizen.Wait(100)
end

TaskPlayAnim(PlayerPedId(), "anim@move_m@prisoner_cuffed", "idle", 8, 8, -1, 57, 1, false, false, false)

This will not get the playerPed to play the Animation.

Importancy

There's a workaround

Area(s)

FiveM

Specific version(s)

FiveM 7667, Server b7375, windows

Additional information

I'm unsure if this applies to other Natives as well, but I guess this is a more general problem.

KooperNinja avatar Mar 24 '24 21:03 KooperNinja

I don't necessarily think this is a bug, these natives expect a float value when called, the only thing that could probably be improved here is the docs using "float" or "decimal" instead of just "number" (this going for JavaScript and Lua)

It should be noted that JavaScript has something to convert the values from number -> floating point number, but this is needed more so in JavaScript because bundlers will strip decimal places

AvarianKnight avatar Mar 24 '24 21:03 AvarianKnight

I just wish itr would error to show people their mistakes while modding.

mcNuggets1 avatar Mar 26 '24 10:03 mcNuggets1

I mean, isn't there a way to convert it to float from the number? Or are there any performance reasons, why this should not work?

KooperNinja avatar Mar 26 '24 10:03 KooperNinja