-
Notifications
You must be signed in to change notification settings - Fork 215
Update main.lua #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update main.lua #272
Conversation
Z3rio
left a comment
There was a problem hiding this 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. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ----------------------- 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. | |
| ----------------------- |
There was a problem hiding this comment.
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
| 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) |
There was a problem hiding this comment.
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.
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