Skip to content
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

New Cruise Control #4

Merged
merged 4 commits into from
Mar 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -105,10 +108,29 @@ Citizen.CreateThread(function()
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