Skip to content

Conversation

@GrossBeanQB
Copy link

Just a slight modification that I've made.

When you enter the vehicle, vehicle is off by default.

You turn it on by pressing G by default bind by QBcore.

When driving, you can turn off the vehicle by pressing G again.

Soft breaking does not turn on the car, nor the W or S as well.

This was made for more "realistic" feel to it.

-GrossBean

Copy link
Contributor

@Z3rio Z3rio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In its current state, this PR is not really fit to be merged, due to the performance impact this would have. Have a look at my comments for tips on how to refactor this. I will gladly give you further pointers.

@@ -1,4 +1,4 @@
-----------------------
----------------------- JUST A SMALL CHANGE. WHEN IN VEHICLE AND YOU PRESS G YOU TURN ON THE VEHICLE, TURNING OFF VEHICLE MID DRIVE PRESSING G, AND YOU CAN'T TURN IT BACK ON USING W OR S, SOFT BREAK ALSO WORKS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
----------------------- JUST A SMALL CHANGE. WHEN IN VEHICLE AND YOU PRESS G YOU TURN ON THE VEHICLE, TURNING OFF VEHICLE MID DRIVE PRESSING G, AND YOU CAN'T TURN IT BACK ON USING W OR S, SOFT BREAK ALSO WORKS.
-----------------------

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the place for such text

Comment on lines +790 to +824
CreateThread(function()
while true do
Wait(0)
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped, false) then
local veh = GetVehiclePedIsIn(ped, false)
local plate = QBCore.Functions.GetPlate(veh)

if GetPedInVehicleSeat(veh, -1) == ped then
if not engineManuallyToggled[plate] then

if GetIsVehicleEngineRunning(veh) then
SetVehicleEngineOn(veh, false, true, true)
end


local speed = GetEntitySpeed(veh)

DisableControlAction(0, 71, true) -- Accelerate (W)
DisableControlAction(0, 86, true) -- Horn (E)


if speed < 1.0 then
DisableControlAction(0, 72, true) -- Brake (S)
end

DisableControlAction(0, 63, true) -- Steer Left (A)
DisableControlAction(0, 64, true) -- Steer Right (D)
end
end
else
Wait(500)
end
end
end)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This most likely does not need to / shouldnt be ran every single frame of being in a vehicle.
Realistically, this should just be ran once upon entering a vehicle.

Nor should we really need to disable controls for this, as that will be done by disabling/turning off the engine.

Looking at the rest of this code, we can probably refactor this to a function that gets ran once upon QBCore:Client:VehicleInfo being triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants