From b129120b5601774a82c3f07c51d5b6b111f81434 Mon Sep 17 00:00:00 2001 From: Vitroze Date: Tue, 27 Oct 2026 00:12:24 +0100 Subject: [PATCH 1/2] Adding cruise control --- lua/entities/base_glide_car/init.lua | 15 ++++++++++++++- lua/entities/base_glide_car/shared.lua | 1 + lua/entities/base_glide_car/sv_engine.lua | 18 ++++++++++++++++++ lua/glide/sh_input.lua | 1 + .../localization/en/glide_vehicles.properties | 3 +++ .../localization/fr/glide_vehicles.properties | 3 +++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lua/entities/base_glide_car/init.lua b/lua/entities/base_glide_car/init.lua index 0ece1eaf..1384934d 100644 --- a/lua/entities/base_glide_car/init.lua +++ b/lua/entities/base_glide_car/init.lua @@ -187,7 +187,7 @@ end function ENT:OnDriverExit() local keepOn = IsValid( self.lastDriver ) and self.lastDriver:KeyDown( IN_WALK ) - if not self.hasTheDriverBeenRagdolled and not keepOn then + if not self.hasTheDriverBeenRagdolled and not keepOn and not self:GetIsCruiseControlEnabled() then self:TurnOff() end @@ -247,6 +247,19 @@ function ENT:OnSeatInput( seatIndex, action, pressed ) elseif action == "accelerate" and self:GetEngineState() == 0 and self:GetEngineRPM() < 1 then self:TurnOn() + elseif action == "toggle_cruise_control" then + self:SetIsCruiseControlEnabled( not self:GetIsCruiseControlEnabled() ) + + if not self:GetIsCruiseControlEnabled() then + self.cruiseTargetSpeed = 0 + end + + Glide.SendNotification( self:GetAllPlayers(), { + text = self:GetIsCruiseControlEnabled() and "#glide.notify.cruise_control_on" or "#glide.notify.cruise_control_off", + icon = "materials/glide/icons/car.png", + immediate = true, + formatArgs = { self:GetIsCruiseControlEnabled() and "on" or "off" } + } ) end if not self.inputManualShift then return end diff --git a/lua/entities/base_glide_car/shared.lua b/lua/entities/base_glide_car/shared.lua index 5b2b39ae..377e767d 100644 --- a/lua/entities/base_glide_car/shared.lua +++ b/lua/entities/base_glide_car/shared.lua @@ -34,6 +34,7 @@ function ENT:SetupDataTables() -- these slots when creating your own on child classes! self:NetworkVar( "Bool", "IsRedlining" ) self:NetworkVar( "Bool", "IsHonking" ) + self:NetworkVar( "Bool", "IsCruiseControlEnabled" ) self:NetworkVar( "Int", "SirenState" ) self:NetworkVar( "Int", "Gear" ) diff --git a/lua/entities/base_glide_car/sv_engine.lua b/lua/entities/base_glide_car/sv_engine.lua index fce0c69c..87d36409 100644 --- a/lua/entities/base_glide_car/sv_engine.lua +++ b/lua/entities/base_glide_car/sv_engine.lua @@ -30,6 +30,8 @@ function ENT:EngineInit() self.avgSideSlip = 0 self.avgPoweredRPM = 0 self.avgForwardSlip = 0 + + self.cruiseTargetSpeed = 0 end --- Returns a list of available transmission gears. @@ -269,6 +271,22 @@ function ENT:EngineThink( dt, selfTbl ) inputBrake = self:GetInputFloat( 1, "brake", selfTbl ) inputHandbrake = self:GetInputBool( 1, "handbrake", selfTbl ) + if self:GetIsCruiseControlEnabled() and not amphibiousMode then + if inputBrake > 0.1 or inputThrottle > 0.1 then + self:SetIsCruiseControlEnabled( false ) + selfTbl.cruiseTargetSpeed = 0 + else + if not selfTbl.cruiseTargetSpeed or selfTbl.cruiseTargetSpeed < 0.1 then + selfTbl.cruiseTargetSpeed = Max( selfTbl.forwardSpeed, 0 ) + end + + local cruiseThrottle = Clamp( ( selfTbl.cruiseTargetSpeed - selfTbl.forwardSpeed ) * 0.01, 0, 1 ) + + inputThrottle = Max( inputThrottle, cruiseThrottle ) + inputBrake = 0 + end + end + if amphibiousMode then selfTbl.burnout = 0 self:BoatEngineThink( dt ) diff --git a/lua/glide/sh_input.lua b/lua/glide/sh_input.lua index aedad742..84464b66 100644 --- a/lua/glide/sh_input.lua +++ b/lua/glide/sh_input.lua @@ -95,6 +95,7 @@ Glide.AddInputAction( "land_controls", "throttle_modifier", KEY_LSHIFT ) Glide.AddInputAction( "land_controls", "horn", KEY_R ) Glide.AddInputAction( "land_controls", "siren", KEY_L ) Glide.AddInputAction( "land_controls", "detach_trailer", KEY_K ) +Glide.AddInputAction( "land_controls", "toggle_cruise_control", KEY_C ) Glide.AddInputAction( "land_controls", "lean_forward", KEY_UP ) Glide.AddInputAction( "land_controls", "lean_back", KEY_DOWN ) diff --git a/resource/localization/en/glide_vehicles.properties b/resource/localization/en/glide_vehicles.properties index 29e406e7..8fb6c805 100644 --- a/resource/localization/en/glide_vehicles.properties +++ b/resource/localization/en/glide_vehicles.properties @@ -80,6 +80,7 @@ glide.input.siren=Siren glide.input.headlights=Toggle headlights glide.input.toggle_engine=Toggle engine glide.input.detach_trailer=Detach trailer +glide.input.cruise_control=Cruise control glide.input.throttle_modifier=Throttle modifier glide.input.throttle_mod_mode=Throttle modifier mode @@ -197,6 +198,8 @@ glide.notify.vehicle_locked=This vehicle has been locked, only the vehicle creat glide.notify.vehicle_unlocked=This vehicle has been unlocked, anyone can enter it. glide.notify.reduced_throttle_on=Reduced throttle. glide.notify.reduced_throttle_off=Full throttle. +glide.notify.cruise_control_on=You have activated cruise control. +glide.notify.cruise_control_off=You have deactivated cruise control. glide.notify.tip.headlights=Press %s to switch headlights.\n\nYou can also configure if they should turn on/off automatically when you are on a dim place. glide.notify.tip.homing_launcher=Hold the right mouse button to lock on occupied vehicles. glide.notify.tip.heli_controls=Use the mouse to aim the helicopter.\n\nYou can switch to WAC-like or GTA-like controls in the settings. diff --git a/resource/localization/fr/glide_vehicles.properties b/resource/localization/fr/glide_vehicles.properties index a0acac92..cd57e409 100644 --- a/resource/localization/fr/glide_vehicles.properties +++ b/resource/localization/fr/glide_vehicles.properties @@ -80,6 +80,7 @@ glide.input.siren=Sirène glide.input.headlights=Activer/désactiver les phares glide.input.toggle_engine=Allumer/éteindre le moteur glide.input.detach_trailer=Détacher la remorque +glide.input.cruise_control=Régulateur de vitesse glide.input.throttle_modifier=Modificateur d'accélérateur glide.input.throttle_mod_mode=Mode de modif. d'accélérateur @@ -198,6 +199,8 @@ glide.notify.vehicle_locked=Ce véhicule a été verrouillé, seuls le créateur glide.notify.vehicle_unlocked=Ce véhicule a été déverrouillé, tout le monde peut y entrer. glide.notify.reduced_throttle_on=Gaz réduit. glide.notify.reduced_throttle_off=Plein régime. +glide.notify.cruise_control_on=Vous avez activé le régulateur de vitesse. +glide.notify.cruise_control_off=Vous avez désactivé le régulateur de vitesse. glide.notify.tip.headlights=Appuyez sur %s pour allumer/éteindre les phares.\n\nVous pouvez également configurer leur activation/désactivation automatique dans les endroits sombres. glide.notify.tip.homing_launcher=Maintenez le clic droit pour verrouiller les véhicules occupés. glide.notify.tip.heli_controls=Utilisez la souris pour piloter l'hélicoptère.\n\nVous pouvez passer à des contrôles de style WAC ou GTA dans les paramètres. From 9bfa51cd53b6a3ce4d7ee1daa8d593208177f496 Mon Sep 17 00:00:00 2001 From: Vitroze Date: Tue, 27 Oct 2026 00:32:23 +0100 Subject: [PATCH 2/2] Add cruise control icon to vehicle HUD and include icon file --- lua/entities/base_glide_car/cl_init.lua | 3 +++ materials/glide/icons/cruise_control.png | Bin 0 -> 9335 bytes 2 files changed, 3 insertions(+) create mode 100644 materials/glide/icons/cruise_control.png diff --git a/lua/entities/base_glide_car/cl_init.lua b/lua/entities/base_glide_car/cl_init.lua index 41407d9e..ff19f314 100644 --- a/lua/entities/base_glide_car/cl_init.lua +++ b/lua/entities/base_glide_car/cl_init.lua @@ -521,6 +521,9 @@ function ENT:DrawVehicleHUD( screenW, screenH ) local iconSize = size * 0.11 DrawIcon( x + size - iconSize, y + size - iconSize * 0.5, "glide/icons/engine.png", iconSize, self:IsEngineOn() and colors.icon or colors.iconDisabled ) + -- Cruise control state + DrawIcon( x + size - iconSize * 2.12, y + size - iconSize * 0.5, "glide/icons/cruise_control.png", iconSize, self:GetIsCruiseControlEnabled() and colors.icon or colors.iconDisabled ) + -- Engine RPM local stream = self.stream local meterR = r * 0.9 diff --git a/materials/glide/icons/cruise_control.png b/materials/glide/icons/cruise_control.png new file mode 100644 index 0000000000000000000000000000000000000000..07932406e4cc1c22b1a72e9c6b83881203c48f0d GIT binary patch literal 9335 zcmeHLc{r49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