Event to make a ragdolled ped get up again (unragdoll)
There currently does not seem to be any functionality to either ragdoll someone properly without them getting up again automatically after some time (SetPedToRagdoll) or get up from being ragdolled at all!
There is just one variable for time in SetPedToRagdoll THAT can't be reset, even though I was thinking, ResetPedRagdollTimer would do that. SetPedToRagdoll also twitches the ragdoll, every time, it is applied again.
Calling ClearPedTasks does nothing on a ragdolled player, ClearPedTasksImmediately t-poses the player for a bit and the returns to the base idle animation. (No get up animation whatsoever here)
I would suggest exposing more natives regarding ragdolling or giving some type of way to unragdoll a player atleast.
Sounds like a feature request not a issue ¯_(ツ)_/¯
I believe you can use RESET_PED_RAGDOLL_TIMER to make ped get out of ragdoll state earlier.
I believe you can use
RESET_PED_RAGDOLL_TIMERto make ped get out of ragdoll state earlier.
That does not work.
I think clever use of RESET_PED_RAGDOLL_TIMER can still achieve what you are trying to capture: A way to ragdoll indefinitely, or until some condition is met (e.g., no longer knocked out), that allows a proper exiting of the CTaskNMRelax (iirc) task. Hand-waving a bit:
SetPedToRagdoll(PlayerPedId(), 100, 200, 0, false, false, false)
while SomeCondition do
Wait(0)
ResetPedRagdollTimer(PlayerPedId())
end
ResetPedRagdollTimer does not do anything. It does not stop the last ragdoll timer, the player still gets up after the time configured in SetPedToRagdoll in my tests.
Can you provide an example as to how you are running/testing this?
SetPedToRagdoll(ped, 1000, 1000, 0, false, false, false) in a 0 wait loop, as otherwise it just does not work. Any value above 10~ seconds also seems to be ignored. After the loop has ended, I call ResetPedRagdollTimer.
I also found out, that SetPedToRagdoll has instances, in which other players do see the player as standing.
Using
local timeToRagdoll = 10000
local ped = PlayerPedId()
local ragdoll = true
SetPedToRagdoll(ped, 10, 10, 0, false, false, false)
CreateThread(function()
while ragdoll do
Wait(0)
ResetPedRagdollTimer(ped)
end
end)
Wait(timeToRagdoll)
ragdoll = false
works perfectly fine for me and achieves exactly what you're asking for.
ResetPedRagdollTimer does not reset the end time of the ragdoll task, but rather resets the start time, making this an infinite task when repeatedly called. (This is also intended to be called every frame)
Ah I totally misunerstood the function, it now makes much more sense. Thanks for clarifying that!
I tried using it. It did work for the local player, but for other players the ragdoll is twitching, trying to get up, etc.
https://github.com/citizenfx/fivem/assets/18447482/0b9124f8-003d-460b-ae16-1def56831716
It shows this to other players.
Works perfectly fine for me. However, if you're trying to reset the ragdoll timer on a remotely owned ped this won't work for obv reasons. This only works on the local player ped or peds the client has network ownership of (working around this limitation in code should be easy though, e.g. network events/state bags/...).
https://github.com/citizenfx/fivem/assets/57523343/6d466a34-4bc3-4477-8375-6f33c4e07920
As soon as you hit the ped, it begins twitching and trying to get up, if you dont run EnableBoundAnkles (or whatever). Even when activated, the player still twitches for others and sometimes for themselves. Calling SetPedToRagdoll every frame sort of fixes that, but introduces new issues such as desyincing. I would make a video, but I dont have any software for it, currently.
Also the networking is completely broken for ragdolls. It shows a completely false position sometimes.
That isn't a bug, physics for peds are completely client sided so where they rag-doll will be different for every client.
That isn't a bug, physics for peds are completely client sided so where they rag-doll will be different for every client.
The position of the ped is still corrected for a certain period of time. It just stops after some time.
NetworkCreateSynchronisedScene needs the player to be not ragdolled to be executed properly. Here we have a usage for an Unragdoll native now. ClearPedTasksImmediately takes up to 100ms to properly do it.