From ba9b45b82ef3d3780d4470cce53b5b51f98e537c Mon Sep 17 00:00:00 2001 From: tabarra <1808295+tabarra@users.noreply.github.com> Date: Sat, 12 Oct 2024 20:41:39 -0300 Subject: [PATCH] fix(menu): fixed-ish ragdolling and damage when leaving noclip --- resource/menu/client/cl_player_mode.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/resource/menu/client/cl_player_mode.lua b/resource/menu/client/cl_player_mode.lua index 82e000e17..0d754748e 100644 --- a/resource/menu/client/cl_player_mode.lua +++ b/resource/menu/client/cl_player_mode.lua @@ -46,6 +46,26 @@ local function toggleGodMode(enabled) SetEntityInvincible(PlayerPedId(), enabled) end +local function disableRagdollingWhileFall() + CreateThread(function() + local ped = PlayerPedId() + local initialCanPlayerRagdoll = CanPedRagdoll(ped) + SetPedCanRagdoll(ped, false) + + --It takes some time for player to start to fall after noclip disabled + --Also, toggleGodMode(false) is called when disabling noclip + Wait(250) + + SetEntityInvincible(ped, true) + while IsPedFalling(ped) do + Wait(50) + end + Wait(1000) + SetPedCanRagdoll(ped, initialCanPlayerRagdoll) + SetEntityInvincible(ped, false) + end) +end + local freecamVeh = 0 local isVehAHorse = false local setLocallyInvisibleFunc = IS_FIVEM and SetEntityLocallyInvisible or SetPlayerInvisibleLocally @@ -121,6 +141,9 @@ local function toggleFreecam(enabled) end local function disableNoClip() + if freecamVeh == 0 then + disableRagdollingWhileFall() + end SetFreecamActive(false) if IS_FIVEM then SetGameplayCamRelativeHeading(0)