From 42e086a54ccf4aab849e1196807c949e68a094ad Mon Sep 17 00:00:00 2001 From: Seef0x <47392375+Seef0x@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:43:43 +0200 Subject: [PATCH 1/4] Add carkill setting --- lua/svmod/config/sh_config.lua | 3 +- lua/svmod/config/sv_config.lua | 3 +- lua/svmod/gui/settings/cl_others.lua | 34 +++++++++++++++++++++++ lua/svmod/gui/settings/cl_settings.lua | 1 + lua/svmod/gui/settings/sv_settings.lua | 1 + lua/svmod/health/sv_health.lua | 10 +++++++ resource/localization/en/svmod.properties | 2 ++ resource/localization/fr/svmod.properties | 2 ++ 8 files changed, 54 insertions(+), 2 deletions(-) diff --git a/lua/svmod/config/sh_config.lua b/lua/svmod/config/sh_config.lua index 44842a3..f806d25 100644 --- a/lua/svmod/config/sh_config.lua +++ b/lua/svmod/config/sh_config.lua @@ -71,7 +71,8 @@ function SVMOD:Load() HUDPositionY = 0.92, HUDSize = 90, HUDColor = Color(178, 95, 245), - CustomSuspension = 0 + CustomSuspension = 0, + IsCarkillEnabled = true } SVMOD:Save() SVMOD:PrintConsole(SVMOD.LOG.Info, "Configuration file server-side converted from 1.3 to 1.4.") diff --git a/lua/svmod/config/sv_config.lua b/lua/svmod/config/sv_config.lua index 9168fe7..59dddb5 100644 --- a/lua/svmod/config/sv_config.lua +++ b/lua/svmod/config/sv_config.lua @@ -61,7 +61,8 @@ function SVMOD:ResetConfiguration() HUDPositionY = 0.91, HUDSize = 100, HUDColor = Color(178, 95, 245), - CustomSuspension = 0 + CustomSuspension = 0, + IsCarkillEnabled = true } SVMOD.CFG.Contributor = { diff --git a/lua/svmod/gui/settings/cl_others.lua b/lua/svmod/gui/settings/cl_others.lua index a7066dd..b0b9392 100644 --- a/lua/svmod/gui/settings/cl_others.lua +++ b/lua/svmod/gui/settings/cl_others.lua @@ -115,4 +115,38 @@ function SVMOD:GUI_Others(panel, data) slide:SetMinValue(-10) slide:SetMaxValue(10) slide:SetUnit("") + + local title = SVMOD:CreateTitle(panel, language.GetPhrase("svmod.others.carkill")) + title:DockMargin(0, 10, 0, 0) + + SVMOD:CreateSettingPanel(panel, language.GetPhrase("svmod.sounds.enable_carkill"), { + { + Name = language.GetPhrase("svmod.enable"), + Color = Color(59, 217, 85), + HoverColor = Color(156, 255, 161), + IsSelected = (data.IsCarkillEnabled == true), + DoClick = function() + net.Start("SV_Settings") + net.WriteString("Others") + net.WriteString("IsCarkillEnabled") + net.WriteUInt(0, 2) -- bool + net.WriteBool(true) + net.SendToServer() + end + }, + { + Name = language.GetPhrase("svmod.disable"), + Color = Color(173, 48, 43), + HoverColor = Color(224, 62, 56), + IsSelected = (data.IsCarkillEnabled == false), + DoClick = function() + net.Start("SV_Settings") + net.WriteString("Others") + net.WriteString("IsCarkillEnabled") + net.WriteUInt(0, 2) -- bool + net.WriteBool(false) + net.SendToServer() + end + } + }) end \ No newline at end of file diff --git a/lua/svmod/gui/settings/cl_settings.lua b/lua/svmod/gui/settings/cl_settings.lua index a76b48c..7d2e37b 100644 --- a/lua/svmod/gui/settings/cl_settings.lua +++ b/lua/svmod/gui/settings/cl_settings.lua @@ -47,6 +47,7 @@ net.Receive("SV_Settings", function() data.HUDSize = net.ReadUInt(9) -- max: 511 data.HUDColor = net.ReadColor() data.CustomSuspension = math.Round(net.ReadFloat(), 2) + data.IsCarkillEnabled = net.ReadBool() data.EnterpriseID = net.ReadFloat() end diff --git a/lua/svmod/gui/settings/sv_settings.lua b/lua/svmod/gui/settings/sv_settings.lua index 490d139..6f10572 100644 --- a/lua/svmod/gui/settings/sv_settings.lua +++ b/lua/svmod/gui/settings/sv_settings.lua @@ -58,6 +58,7 @@ concommand.Add("svmod", function(ply) net.WriteUInt(SVMOD.CFG["Others"]["HUDSize"], 9) -- max: 511 net.WriteColor(SVMOD.CFG["Others"]["HUDColor"]) net.WriteFloat(SVMOD.CFG["Others"]["CustomSuspension"]) + net.WriteBool(SVMOD.CFG["Others"]["IsCarkillEnabled"]) net.WriteFloat(SVMOD.CFG["Contributor"]["EnterpriseID"]) end diff --git a/lua/svmod/health/sv_health.lua b/lua/svmod/health/sv_health.lua index 834382e..c2a4ce6 100644 --- a/lua/svmod/health/sv_health.lua +++ b/lua/svmod/health/sv_health.lua @@ -272,4 +272,14 @@ hook.Add("SV_PlayerLeaveVehicle", "SV_DealDamageOnLeave", function(ply, veh) DInfo:SetDamage(math.Round(speed / 5 * SVMOD.CFG.Damage.PlayerExitMultiplier)) DInfo:SetDamageType(DMG_VEHICLE) ply:TakeDamageInfo(DInfo) +end) + +hook.Add("EntityTakeDamage", "SV_CarKill", function(victim, dmg) + local ent = dmg:GetInflictor() + + if SVMOD.CFG.Others.IsCarkillEnabled or not victim:IsPlayer() or not SVMOD:IsVehicle(ent) or not ent:SV_IsDriverSeat() then + return + end + + return true end) \ No newline at end of file diff --git a/resource/localization/en/svmod.properties b/resource/localization/en/svmod.properties index f94213c..5dce2f6 100644 --- a/resource/localization/en/svmod.properties +++ b/resource/localization/en/svmod.properties @@ -134,6 +134,8 @@ svmod.others.hud_size=Size svmod.others.hud_color=Color svmod.others.wheels=WHEELS svmod.others.custom_suspension=Custom suspension of the vehicles (0 disabled) +svmod.others.carkill=CARKILL +svmod.others.enable_carkill=Enable the carkill svmod.credits=CREDITS diff --git a/resource/localization/fr/svmod.properties b/resource/localization/fr/svmod.properties index f8b59f7..a9ee512 100644 --- a/resource/localization/fr/svmod.properties +++ b/resource/localization/fr/svmod.properties @@ -135,6 +135,8 @@ svmod.others.hud_size=Taille svmod.others.hud_color=Couleur svmod.others.wheels=PNEUS svmod.others.custom_suspension=Suspension des véhicules customisée (0 désactivé) +svmod.others.carkill=CARKILL +svmod.others.enable_carkill=Activer le carkill svmod.credits=CRÉDITS From 4f9f884d3b354cb54b76917dd2ce177b5f15c43b Mon Sep 17 00:00:00 2001 From: Seef0x <47392375+Seef0x@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:53:45 +0200 Subject: [PATCH 2/4] Fix carkill translation setting --- lua/svmod/gui/settings/cl_others.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/svmod/gui/settings/cl_others.lua b/lua/svmod/gui/settings/cl_others.lua index b0b9392..6fc777d 100644 --- a/lua/svmod/gui/settings/cl_others.lua +++ b/lua/svmod/gui/settings/cl_others.lua @@ -119,7 +119,7 @@ function SVMOD:GUI_Others(panel, data) local title = SVMOD:CreateTitle(panel, language.GetPhrase("svmod.others.carkill")) title:DockMargin(0, 10, 0, 0) - SVMOD:CreateSettingPanel(panel, language.GetPhrase("svmod.sounds.enable_carkill"), { + SVMOD:CreateSettingPanel(panel, language.GetPhrase("svmod.others.enable_carkill"), { { Name = language.GetPhrase("svmod.enable"), Color = Color(59, 217, 85), From 53715c0a2e3ab56cd02e44df9f60147ea0aaaf49 Mon Sep 17 00:00:00 2001 From: Seef0x <47392375+Seef0x@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:59:33 +0200 Subject: [PATCH 3/4] Add carkill en translation in de file --- resource/localization/de/svmod.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resource/localization/de/svmod.properties b/resource/localization/de/svmod.properties index f43f968..8798eb3 100644 --- a/resource/localization/de/svmod.properties +++ b/resource/localization/de/svmod.properties @@ -134,6 +134,8 @@ svmod.others.hud_size=Größe svmod.others.hud_color=Farbe svmod.others.wheels=REIFEN svmod.others.custom_suspension=Individuelle Federung der Fahrzeuge (0 deaktiviert) +svmod.others.carkill=CARKILL +svmod.others.enable_carkill=Enable the carkill svmod.credits=CREDITS From 3ee8bc2fa21068277110dcb9597302fde885e64b Mon Sep 17 00:00:00 2001 From: Seef0x <47392375+Seef0x@users.noreply.github.com> Date: Fri, 4 Aug 2023 21:05:39 +0200 Subject: [PATCH 4/4] Fix carkill setting if it didn't exist --- lua/svmod/config/sh_config.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/svmod/config/sh_config.lua b/lua/svmod/config/sh_config.lua index 1dd453e..fa45b6c 100644 --- a/lua/svmod/config/sh_config.lua +++ b/lua/svmod/config/sh_config.lua @@ -51,6 +51,10 @@ function SVMOD:Load() if SERVER then self.CFG.Others.HUDColor = Color(self.CFG.Others.HUDColor.r, self.CFG.Others.HUDColor.g, self.CFG.Others.HUDColor.b) + + if SVMOD.CFG.Others.IsCarkillEnabled == nil then + SVMOD.CFG.Others.IsCarkillEnabled = true + end elseif self.CFG.Shortcuts then -- CLIENT for i, s in ipairs(self.CFG.Shortcuts) do