Skip to content

Commit

Permalink
(fix) Prevents player from spawning car when frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
Yorick20022 authored Oct 22, 2024
1 parent 8cbc767 commit 2bab95a
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions resource/menu/client/cl_freeze.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,48 @@ RegisterNetEvent('txcl:freezePlayerOk', function(isFrozen)
sendSnackbarMessage('info', localeKey, true)
end)

local isPlayerFrozen = false

RegisterNetEvent('txcl:setFrozen', function(isFrozen)
debugPrint('Frozen: ' .. tostring(isFrozen))
--NOTE: removed the check for vehicle, but could be done with
--NOTE: removed the check for vehicle, but could be done with
-- IsPedInAnyVehicle for vehicles and IsPedOnMount for horses
local playerPed = PlayerPedId()
TaskLeaveAnyVehicle(playerPed, 0, 16)

if isFrozen and IsPedInAnyVehicle(playerPed, false) then
TaskLeaveAnyVehicle(playerPed, 0, 16)
end

isPlayerFrozen = isFrozen
FreezeEntityPosition(playerPed, isFrozen)
sendFreezeAlert(isFrozen)

-- Logic to delete vehicle/horse that the player is trying to spawn
if isFrozen then
CreateThread(function()
while isPlayerFrozen do
if IS_FIVEM then
if IsPedInAnyVehicle(playerPed, false) then
local veh = GetVehiclePedIsUsing(playerPed)
Wait(0)
if DoesEntityExist(veh) then
DeleteEntity(veh)
end
end
Wait(100)
else
if IS_REDM then
if IsPedOnMount(playerPed) then
local horse = GetVehiclePedIsUsing(playerPed)
Wait(0)
if DoesEntityExist(horse) then
DeleteEntity(horse)
end
end
Wait(100)
end
end
end
end)
end
end)

0 comments on commit 2bab95a

Please sign in to comment.