Skip to content

Commit

Permalink
Fix Cruise Control
Browse files Browse the repository at this point in the history
So we are getting wrong about cruise control. We though it is a speed limit function but it not. 
Now we are will merge this pull request to main branch.

Thanks for @xerenon for contribute with project.
  • Loading branch information
xerenon authored Mar 14, 2021
1 parent ffe6421 commit 75602a7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ local vehData = {
prevVelocity = {x = 0.0, y = 0.0, z = 0.0},
};

local inair = 0
local cruiseSpeeding = 0

local playerPed = nil;
-- Thread
Citizen.CreateThread(function()
Expand Down Expand Up @@ -103,10 +106,29 @@ Citizen.CreateThread(function()
cruiseEnabled = not cruiseEnabled;
triggerNUI("toggleCruise", { hasCruise = isDriver, cruiseStatus = cruiseEnabled });
vehData['cruiseSpd'] = vehData['currSpd'];
cruiseSpeeding = vehData['cruiseSpd'];
end

local maxSpeed = cruiseEnabled and vehData['cruiseSpd'] or GetVehicleHandlingFloat(currVeh,"CHandlingData","fInitialDriveMaxFlatVel");
SetEntityMaxSpeed(currVeh, maxSpeed);

local roll = GetEntityRoll(currVeh)


if cruiseEnabled and not IsEntityInAir(currVeh) and inair >= 100 and not (roll > 75.0 or roll < -75.0) then
if cruiseSpeeding < maxSpeed then
cruiseSpeeding = cruiseSpeeding + 0.15
end


SetVehicleForwardSpeed(currVeh, cruiseSpeeding)

elseif cruiseEnabled and not IsEntityInAir(currVeh) then
inair = inair + 1
cruiseSpeeding = vehData['currSpd'];
elseif cruiseEnabled then
inair = 0
end
else
cruiseEnabled = false;
end
Expand Down

0 comments on commit 75602a7

Please sign in to comment.