Skip to content

Commit

Permalink
Update main.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
warlikeprince authored Jun 14, 2024
1 parent 46ac5ca commit 780b66b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ RegisterNetEvent('qb-vehiclekeys:client:RemoveKeys', function(plate)
end)

RegisterNetEvent('qb-vehiclekeys:client:ToggleEngine', function()
local EngineOn = GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId()))
local vehicle = GetVehiclePedIsIn(PlayerPedId(), true)
local EngineOn = GetIsVehicleEngineRunning(vehicle)
if HasKeys(QBCore.Functions.GetPlate(vehicle)) then
if EngineOn then
SetVehicleEngineOn(vehicle, false, false, true)
Expand Down Expand Up @@ -777,3 +777,22 @@ RegisterNUICallback('engine', function()
ToggleEngine(GetVehicle())
SetNuiFocus(false, false)
end)

-- New function to disable vehicle controls when the engine is off
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
local vehicle = GetVehiclePedIsIn(playerPed, false)

if vehicle and GetPedInVehicleSeat(vehicle, -1) == playerPed then
if not GetIsVehicleEngineRunning(vehicle) then
-- Disable controls if the engine is off
DisableControlAction(0, 71, true) -- Disable acceleration
DisableControlAction(0, 72, true) -- Disable braking
DisableControlAction(0, 63, true) -- Disable left turn
DisableControlAction(0, 64, true) -- Disable right turn
end
end
end
end)

0 comments on commit 780b66b

Please sign in to comment.