Skip to content

Commit

Permalink
fix(menu): fixed-ish ragdolling and damage when leaving noclip
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Oct 12, 2024
1 parent 08b4af8 commit ba9b45b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions resource/menu/client/cl_player_mode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ba9b45b

Please sign in to comment.