From 804c11767f741162bbb41b7fac104dbb91fb1251 Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sun, 7 Dec 2025 23:52:08 +0100 Subject: [PATCH 1/7] Adding a parameter --- lua/glide/sh_input.lua | 1 + resource/localization/en/glide_vehicles.properties | 1 + resource/localization/fr/glide_vehicles.properties | 1 + 3 files changed, 3 insertions(+) diff --git a/lua/glide/sh_input.lua b/lua/glide/sh_input.lua index 55b79794..7815452f 100644 --- a/lua/glide/sh_input.lua +++ b/lua/glide/sh_input.lua @@ -93,6 +93,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", "flashinglights", KEY_M ) Glide.AddInputAction( "land_controls", "detach_trailer", KEY_K ) Glide.AddInputAction( "land_controls", "lean_forward", KEY_UP ) diff --git a/resource/localization/en/glide_vehicles.properties b/resource/localization/en/glide_vehicles.properties index b7567478..7e8d1860 100644 --- a/resource/localization/en/glide_vehicles.properties +++ b/resource/localization/en/glide_vehicles.properties @@ -77,6 +77,7 @@ glide.input.brake=Brake/Reverse glide.input.handbrake=Handbrake glide.input.horn=Horn glide.input.siren=Siren +glide.input.flashinglights=Flashing lights glide.input.headlights=Toggle headlights glide.input.toggle_engine=Toggle engine glide.input.detach_trailer=Detach trailer diff --git a/resource/localization/fr/glide_vehicles.properties b/resource/localization/fr/glide_vehicles.properties index 1cf814fb..57b80239 100644 --- a/resource/localization/fr/glide_vehicles.properties +++ b/resource/localization/fr/glide_vehicles.properties @@ -77,6 +77,7 @@ glide.input.brake=Freiner/Reculer glide.input.handbrake=Frein à main glide.input.horn=Klaxon glide.input.siren=Sirène +glide.input.flashinglights=Gyrophare glide.input.headlights=Activer/désactiver les phares glide.input.toggle_engine=Allumer/éteindre le moteur glide.input.detach_trailer=Détacher la remorque From 3c861d0b1a7bfdb47b90cbad2b2278c7af27940e Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sun, 7 Dec 2025 23:53:10 +0100 Subject: [PATCH 2/7] Separation of flashing lights and sirens. Added the ability to have multiple flashing lights on a vehicle. --- lua/entities/base_glide_car/cl_init.lua | 13 ++++++++----- lua/entities/base_glide_car/init.lua | 16 +++++++++++++--- lua/entities/base_glide_car/shared.lua | 1 + 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lua/entities/base_glide_car/cl_init.lua b/lua/entities/base_glide_car/cl_init.lua index bcac5a9f..0e5bfb52 100644 --- a/lua/entities/base_glide_car/cl_init.lua +++ b/lua/entities/base_glide_car/cl_init.lua @@ -133,7 +133,9 @@ function ENT:OnUpdateSounds() if sounds.siren then sounds.siren:ChangeVolume( self.SirenVolume * GetVolume( "hornVolume" ) ) else - local snd = self:CreateLoopingSound( "siren", Glide.GetRandomSound( self.SirenLoopSound ), 90, self ) + local siren = self:GetSirenState() + local snd = self:CreateLoopingSound( "siren", self.SirenVehicle and self.SirenVehicle[siren] or Glide.GetRandomSound( self.SirenLoopSound ), 90, self ) + snd:PlayEx( self.SirenVolume * GetVolume( "hornVolume" ), 100 ) end @@ -288,13 +290,14 @@ function ENT:OnUpdateMisc() -- Siren lights/bodygroups local siren = self:GetSirenState() + local flashing = self:GetFlashingState() - if self.lastSirenState ~= siren then + if self.lastSirenState ~= siren or self.lastFlashingState ~= flashing then self.lastSirenState = siren + self.lastFlashingState = flashing - if siren > 1 then + if siren > 0 then self.lastSirenEnableTime = CurTime() - elseif self.lastSirenEnableTime then if CurTime() - self.lastSirenEnableTime < 0.25 then Glide.PlaySoundSet( self.SirenInterruptSound, self, self.SirenVolume ) @@ -311,7 +314,7 @@ function ENT:OnUpdateMisc() end end - if siren < 1 then return end + if flashing < 1 then return end local myPos = self:GetPos() local t = ( CurTime() % self.SirenCycle ) / self.SirenCycle diff --git a/lua/entities/base_glide_car/init.lua b/lua/entities/base_glide_car/init.lua index 1030199d..f680dbd1 100644 --- a/lua/entities/base_glide_car/init.lua +++ b/lua/entities/base_glide_car/init.lua @@ -207,7 +207,8 @@ function ENT:OnSeatInput( seatIndex, action, pressed ) if action == "siren" then self:ChangeSirenState( self:GetSirenState() + 1 ) - + elseif action == "flashinglights" then + self:ChangeFlashingState( self:GetFlashingState() + 1 ) elseif action == "accelerate" and self:GetEngineState() == 0 and self:GetEngineRPM() < 1 then self:TurnOn() end @@ -262,8 +263,8 @@ function ENT:ChangeSirenState( state ) state = math.floor( state ) - if state < 0 then state = 2 end - if state > 2 then state = 0 end + if state < 0 then state = 1 end + if state > ( self.SirenVehicle and #self.SirenVehicle or 1 ) then state = 0 end self:SetSirenState( state ) @@ -272,6 +273,15 @@ function ENT:ChangeSirenState( state ) end end +function ENT:ChangeFlashingState( state ) + state = math.floor( state ) + + if state < 0 then state = 1 end + if state > 1 then state = 0 end + + self:SetFlashingState( state ) +end + --- Override this base class function. function ENT:SetupWiremodPorts( inputs, outputs ) BaseClass.SetupWiremodPorts( self, inputs, outputs ) diff --git a/lua/entities/base_glide_car/shared.lua b/lua/entities/base_glide_car/shared.lua index 0e205a2e..e984fedb 100644 --- a/lua/entities/base_glide_car/shared.lua +++ b/lua/entities/base_glide_car/shared.lua @@ -35,6 +35,7 @@ function ENT:SetupDataTables() self:NetworkVar( "Bool", "IsRedlining" ) self:NetworkVar( "Bool", "IsHonking" ) self:NetworkVar( "Int", "SirenState" ) + self:NetworkVar( "Int", "FlashingState" ) self:NetworkVar( "Int", "Gear" ) self:NetworkVar( "Float", "Steering" ) From c40d64913396f87db0edabd73e4c9539193c00e3 Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sun, 7 Dec 2025 23:54:46 +0100 Subject: [PATCH 3/7] Adding a sample vehicle --- lua/entities/gtav_police_cruiser.lua | 69 +++++++++++++++------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/lua/entities/gtav_police_cruiser.lua b/lua/entities/gtav_police_cruiser.lua index 3de11e09..a6389ec4 100644 --- a/lua/entities/gtav_police_cruiser.lua +++ b/lua/entities/gtav_police_cruiser.lua @@ -7,6 +7,11 @@ ENT.PrintName = "Police Cruiser" ENT.GlideCategory = "Default" ENT.ChassisModel = "models/gta5/vehicles/police/chassis.mdl" ENT.CanSwitchSiren = true +ENT.SirenVehicle = { + Glide.GetRandomSound( ENT.SirenLoopSound ), + "glide/horns/police_horn_2.wav", + "glide/alarms/police_siren_1.wav", +} function ENT:GetFirstPersonOffset( _, localEyePos ) localEyePos[1] = localEyePos[1] + 5 @@ -59,37 +64,39 @@ if CLIENT then } ENT.SirenLights = { - -- Top-right (blue) lights - { offset = Vector( -6, -21, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, - { offset = Vector( -6, -21, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, - { offset = Vector( -6, -11, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, - { offset = Vector( -6, -11, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, - - -- Top-left (red) lights - { offset = Vector( -6, 21, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, - { offset = Vector( -6, 21, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, - { offset = Vector( -6, 11, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, - { offset = Vector( -6, 11, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, - - -- Top bodygroups - { bodygroup = 30, time = 0, duration = 0.5 }, - { bodygroup = 31, time = 0.5, duration = 0.5 }, - { bodygroup = 32, time = 0, duration = 0.5 }, - { bodygroup = 27, time = 0.5, duration = 0.5 }, - { bodygroup = 28, time = 0, duration = 0.5 }, - { bodygroup = 29, time = 0.5, duration = 0.5 }, - - -- Front bodygroups - { bodygroup = 26, time = 0, duration = 0.5 }, - { bodygroup = 25, time = 0.5, duration = 0.5 }, - - -- Front-right sprites - { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, - { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, - - -- Front-left sprites - { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 }, - { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 } + { + -- Top-right (blue) lights + { offset = Vector( -6, -21, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, + { offset = Vector( -6, -21, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, + { offset = Vector( -6, -11, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, + { offset = Vector( -6, -11, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, + + -- Top-left (red) lights + { offset = Vector( -6, 21, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, + { offset = Vector( -6, 21, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, + { offset = Vector( -6, 11, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, + { offset = Vector( -6, 11, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, + + -- Top bodygroups + { bodygroup = 30, time = 0, duration = 0.5 }, + { bodygroup = 31, time = 0.5, duration = 0.5 }, + { bodygroup = 32, time = 0, duration = 0.5 }, + { bodygroup = 27, time = 0.5, duration = 0.5 }, + { bodygroup = 28, time = 0, duration = 0.5 }, + { bodygroup = 29, time = 0.5, duration = 0.5 }, + + -- Front bodygroups + { bodygroup = 26, time = 0, duration = 0.5 }, + { bodygroup = 25, time = 0.5, duration = 0.5 }, + + -- Front-right sprites + { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, + { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, + + -- Front-left sprites + { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 }, + { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 } + } } ENT.ExhaustPopSound = "" From ce2fa26d256ea6d3ac01e959ff91f439b0cec8d0 Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sun, 7 Dec 2025 23:59:29 +0100 Subject: [PATCH 4/7] Adding the fact of having multiple flashing lights --- lua/entities/base_glide_car/cl_init.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/entities/base_glide_car/cl_init.lua b/lua/entities/base_glide_car/cl_init.lua index 0e5bfb52..943cb330 100644 --- a/lua/entities/base_glide_car/cl_init.lua +++ b/lua/entities/base_glide_car/cl_init.lua @@ -294,7 +294,6 @@ function ENT:OnUpdateMisc() if self.lastSirenState ~= siren or self.lastFlashingState ~= flashing then self.lastSirenState = siren - self.lastFlashingState = flashing if siren > 0 then self.lastSirenEnableTime = CurTime() @@ -307,11 +306,14 @@ function ENT:OnUpdateMisc() end -- Set bodygroups to default - for _, v in ipairs( self.SirenLights ) do + local SirenLights = self.SirenLights[self.lastFlashingState] or {} + for _, v in ipairs( SirenLights ) do if v.bodygroup then self:SetBodygroup( v.bodygroup, 0 ) end end + + self.lastFlashingState = flashing end if flashing < 1 then return end @@ -322,7 +324,9 @@ function ENT:OnUpdateMisc() local bodygroupState = {} - for _, v in ipairs( self.SirenLights ) do + local SirenLights = self.SirenLights[flashing] or {} + + for _, v in ipairs( SirenLights ) do on = t > v.time and t < v.time + ( v.duration or 0.125 ) -- Check for optional bodygroup requirement From 833434fbaba05531ade1e58389e3a016d9f65625 Mon Sep 17 00:00:00 2001 From: Vitroze Date: Mon, 8 Dec 2025 00:08:30 +0100 Subject: [PATCH 5/7] Implementing vehicle compatibility before the ELS update. --- lua/entities/base_glide_car/cl_init.lua | 4 ++-- lua/entities/base_glide_car/init.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/entities/base_glide_car/cl_init.lua b/lua/entities/base_glide_car/cl_init.lua index 943cb330..6d5c0f38 100644 --- a/lua/entities/base_glide_car/cl_init.lua +++ b/lua/entities/base_glide_car/cl_init.lua @@ -306,7 +306,7 @@ function ENT:OnUpdateMisc() end -- Set bodygroups to default - local SirenLights = self.SirenLights[self.lastFlashingState] or {} + local SirenLights = self.NumberFlashingLights and self.SirenLights[self.lastFlashingState] or self.SirenLights for _, v in ipairs( SirenLights ) do if v.bodygroup then self:SetBodygroup( v.bodygroup, 0 ) @@ -324,7 +324,7 @@ function ENT:OnUpdateMisc() local bodygroupState = {} - local SirenLights = self.SirenLights[flashing] or {} + local SirenLights = self.NumberFlashingLights and self.SirenLights[flashing] or self.SirenLights for _, v in ipairs( SirenLights ) do on = t > v.time and t < v.time + ( v.duration or 0.125 ) diff --git a/lua/entities/base_glide_car/init.lua b/lua/entities/base_glide_car/init.lua index f680dbd1..e691db77 100644 --- a/lua/entities/base_glide_car/init.lua +++ b/lua/entities/base_glide_car/init.lua @@ -277,7 +277,7 @@ function ENT:ChangeFlashingState( state ) state = math.floor( state ) if state < 0 then state = 1 end - if state > 1 then state = 0 end + if state > ( self.NumberFlashingLights or 1 ) then state = 0 end self:SetFlashingState( state ) end From d0f34ab43e5b3cf3b786b9941964a47387c9d92b Mon Sep 17 00:00:00 2001 From: Vitroze Date: Mon, 8 Dec 2025 00:17:20 +0100 Subject: [PATCH 6/7] End of testing on the police cruiser. --- lua/entities/gtav_police_cruiser.lua | 69 +++++++++++++--------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/lua/entities/gtav_police_cruiser.lua b/lua/entities/gtav_police_cruiser.lua index a6389ec4..3de11e09 100644 --- a/lua/entities/gtav_police_cruiser.lua +++ b/lua/entities/gtav_police_cruiser.lua @@ -7,11 +7,6 @@ ENT.PrintName = "Police Cruiser" ENT.GlideCategory = "Default" ENT.ChassisModel = "models/gta5/vehicles/police/chassis.mdl" ENT.CanSwitchSiren = true -ENT.SirenVehicle = { - Glide.GetRandomSound( ENT.SirenLoopSound ), - "glide/horns/police_horn_2.wav", - "glide/alarms/police_siren_1.wav", -} function ENT:GetFirstPersonOffset( _, localEyePos ) localEyePos[1] = localEyePos[1] + 5 @@ -64,39 +59,37 @@ if CLIENT then } ENT.SirenLights = { - { - -- Top-right (blue) lights - { offset = Vector( -6, -21, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, - { offset = Vector( -6, -21, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, - { offset = Vector( -6, -11, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, - { offset = Vector( -6, -11, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, - - -- Top-left (red) lights - { offset = Vector( -6, 21, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, - { offset = Vector( -6, 21, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, - { offset = Vector( -6, 11, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, - { offset = Vector( -6, 11, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, - - -- Top bodygroups - { bodygroup = 30, time = 0, duration = 0.5 }, - { bodygroup = 31, time = 0.5, duration = 0.5 }, - { bodygroup = 32, time = 0, duration = 0.5 }, - { bodygroup = 27, time = 0.5, duration = 0.5 }, - { bodygroup = 28, time = 0, duration = 0.5 }, - { bodygroup = 29, time = 0.5, duration = 0.5 }, - - -- Front bodygroups - { bodygroup = 26, time = 0, duration = 0.5 }, - { bodygroup = 25, time = 0.5, duration = 0.5 }, - - -- Front-right sprites - { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, - { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, - - -- Front-left sprites - { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 }, - { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 } - } + -- Top-right (blue) lights + { offset = Vector( -6, -21, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, + { offset = Vector( -6, -21, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, + { offset = Vector( -6, -11, 41 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B }, + { offset = Vector( -6, -11, 41 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B }, + + -- Top-left (red) lights + { offset = Vector( -6, 21, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, + { offset = Vector( -6, 21, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, + { offset = Vector( -6, 11, 41 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A }, + { offset = Vector( -6, 11, 41 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A }, + + -- Top bodygroups + { bodygroup = 30, time = 0, duration = 0.5 }, + { bodygroup = 31, time = 0.5, duration = 0.5 }, + { bodygroup = 32, time = 0, duration = 0.5 }, + { bodygroup = 27, time = 0.5, duration = 0.5 }, + { bodygroup = 28, time = 0, duration = 0.5 }, + { bodygroup = 29, time = 0.5, duration = 0.5 }, + + -- Front bodygroups + { bodygroup = 26, time = 0, duration = 0.5 }, + { bodygroup = 25, time = 0.5, duration = 0.5 }, + + -- Front-right sprites + { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, + { offset = Vector( 114, -10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.25, color = Glide.DEFAULT_SIREN_COLOR_B, lightRadius = 0 }, + + -- Front-left sprites + { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.5, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 }, + { offset = Vector( 114, 10, 5 ), dir = Vector( 1, 0, 0 ), time = 0.75, color = Glide.DEFAULT_SIREN_COLOR_A, lightRadius = 0 } } ENT.ExhaustPopSound = "" From ddfa11338f66e580fb64e5d4e68da047c680d22b Mon Sep 17 00:00:00 2001 From: Vitroze Date: Mon, 8 Dec 2025 00:24:07 +0100 Subject: [PATCH 7/7] Logic modification --- lua/entities/base_glide_car/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/base_glide_car/init.lua b/lua/entities/base_glide_car/init.lua index e691db77..9e5d0eca 100644 --- a/lua/entities/base_glide_car/init.lua +++ b/lua/entities/base_glide_car/init.lua @@ -263,7 +263,7 @@ function ENT:ChangeSirenState( state ) state = math.floor( state ) - if state < 0 then state = 1 end + if state < 0 then state = self.SirenVehicle and #self.SirenVehicle or 1 end if state > ( self.SirenVehicle and #self.SirenVehicle or 1 ) then state = 0 end self:SetSirenState( state )