Skip to content

Commit

Permalink
Fix entity doesn't exist error on join
Browse files Browse the repository at this point in the history
  • Loading branch information
Flohhhhh committed Dec 8, 2023
1 parent 9ff05cf commit 1914d35
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions real-brake-lights/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ local function onEnteredVehicle(_vehicle)
local brakeLights = false

while true do

-- if i'm not in the vehicle turn off its brake lights and return
if GetVehiclePedIsIn(ped, false) ~= vehicle then
TriggerServerEvent("rbl:setParked", VehToNet(vehicle), true)
return
end

local speed = GetEntitySpeed(vehicle) * 2.236936 -- get speed in MPH
if vehicle == 0 then goto continue end -- if vehicle doesn't exist return
if speed <= threshold and not IsControlPressed(0, 32) then -- if stopped
if not brakeLights then -- if brake lights are not already on, turn them on and start a timer for park state
--print("Enabling for my vehicle")
Expand All @@ -121,6 +123,7 @@ local function onEnteredVehicle(_vehicle)
end
end

::continue::
Wait(250)
end
end)
Expand Down

0 comments on commit 1914d35

Please sign in to comment.