From 45c2c77bc367a3889f1780c22216a0d15f5fc8cd Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Fri, 8 Nov 2024 21:57:50 +0500 Subject: [PATCH] proper arc9 random weapons --- .../gamemode/player_class/player_beatrun.lua | 21 +--------- .../beatrun/gamemode/sh/!Helpers.lua | 41 +++++++++++++++++-- .../beatrun/gamemode/sh/DataTheft.lua | 28 +------------ .../beatrun/gamemode/sh/Deathmatch.lua | 28 +------------ beatrun/gamemodes/beatrun/gamemode/shared.lua | 2 +- version.txt | 2 +- 6 files changed, 42 insertions(+), 80 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 8ab55f9..1f38caa 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -124,26 +124,7 @@ end function PLAYER:Loadout() if GetGlobalBool("GM_DATATHEFT") or GetGlobalBool("GM_DEATHMATCH") then - if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then - for i = 0, 1 do - local randomSWEP = getRandomMGBaseWeapon() - local w = self.Player:Give(randomSWEP.ClassName) - - timer.Simple(1, function() - if w:GetPrimaryAmmoType() ~= -1 then self.Player:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end - if w:GetSecondaryAmmoType() ~= -1 then self.Player:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end - end) - end - else - for _, v in ipairs(BEATRUN_GAMEMODES_LOADOUTS[math.random(#BEATRUN_GAMEMODES_LOADOUTS)]) do - local w = self.Player:Give(v) - - timer.Simple(1, function() - if w:GetPrimaryAmmoType() ~= -1 then self.Player:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end - if w:GetSecondaryAmmoType() ~= -1 then self.Player:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end - end) - end - end + Beatrun_GiveGMWeapon(self.Player) else self.Player:RemoveAllAmmo() end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/!Helpers.lua b/beatrun/gamemodes/beatrun/gamemode/sh/!Helpers.lua index 51a133b..a46d66f 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/!Helpers.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/!Helpers.lua @@ -91,7 +91,12 @@ function playermeta:notUsingRH(wep) end end -function getRandomMGBaseSWEP() +function Beatrun_GiveAmmo(weapon, ply) + if weapon:GetPrimaryAmmoType() ~= -1 then ply:GiveAmmo(10000, weapon:GetPrimaryAmmoType(), true) end + if weapon:GetSecondaryAmmoType() ~= -1 then ply:GiveAmmo(5, weapon:GetSecondaryAmmoType(), true) end +end + +function Beatrun_getRandomMWBaseSWEP() local allWep = weapons.GetList() local wepIndex = math.random(#allWep) local wep = allWep[wepIndex] @@ -99,11 +104,11 @@ function getRandomMGBaseSWEP() if wep.Base == "mg_base" and not wep.AdminOnly then return wep else - return getRandomMGBaseSWEP() + return Beatrun_getRandomMWBaseSWEP() end end -function getRandomARC9SWEP() +function Beatrun_getRandomARC9SWEP() local allWep = weapons.GetList() local wepIndex = math.random(#allWep) local wep = allWep[wepIndex] @@ -111,6 +116,34 @@ function getRandomARC9SWEP() if wep.Base == "arc9_cod2019_base" and not wep.AdminOnly then return wep else - return getRandomARC9SWEP() + return Beatrun_getRandomARC9SWEP() + end +end + +function Beatrun_GiveGMWeapon(ply) + if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() and not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() then + for i = 0, 1 do + local swep = Beatrun_getRandomMWBaseSWEP() + local w = ply:Give(swep.ClassName) + + timer.Simple(1, function() + Beatrun_GiveAmmo(w, ply) + end) + end + elseif GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() and not GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then + for i = 0, 1 do + -- We don't need ammo because ARC9 got the infinite ammo option! + + local swep = Beatrun_getRandomARC9SWEP() + ply:Give(swep.ClassName) + end + elseif not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() and not GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then + for _, b in ipairs(BEATRUN_GAMEMODES_LOADOUTS[math.random(#BEATRUN_GAMEMODES_LOADOUTS)]) do + local w = v:Give(b) + + timer.Simple(1, function() + Beatrun_GiveAmmo(w, ply) + end) + end end end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/DataTheft.lua b/beatrun/gamemodes/beatrun/gamemode/sh/DataTheft.lua index a4fe1d3..1ab2fb5 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/DataTheft.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/DataTheft.lua @@ -22,33 +22,7 @@ if SERVER then v:Spawn() end - if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() and not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() then - for i = 0, 1 do - local swep = getRandomMGBaseSWEP() - local w = v:Give(swep.ClassName) - - timer.Simple(1, function() - if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end - if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end - end) - end - elseif GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() and not GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then - for i = 0, 1 do - -- We don't need ammo because ARC9 got the infinite ammo option! - - local swep = getRandomARC9SWEP() - v:Give(swep.ClassName) - end - elseif not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() and not GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then - for _, b in ipairs(BEATRUN_GAMEMODES_LOADOUTS[math.random(#BEATRUN_GAMEMODES_LOADOUTS)]) do - local w = v:Give(b) - - timer.Simple(1, function() - if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end - if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end - end) - end - end + Beatrun_GiveGMWeapon(v) end end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Deathmatch.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Deathmatch.lua index 700326a..881ae3d 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Deathmatch.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Deathmatch.lua @@ -17,33 +17,7 @@ if SERVER then v:Spawn() end - if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() and not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() then - for i = 0, 1 do - local swep = getRandomMGBaseSWEP() - local w = v:Give(swep.ClassName) - - timer.Simple(1, function() - if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end - if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end - end) - end - elseif GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() and not GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then - for i = 0, 1 do - -- We don't need ammo because ARC9 got the infinite ammo option! - - local swep = getRandomARC9SWEP() - v:Give(swep.ClassName) - end - elseif not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() and not GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then - for _, b in ipairs(BEATRUN_GAMEMODES_LOADOUTS[math.random(#BEATRUN_GAMEMODES_LOADOUTS)]) do - local w = v:Give(b) - - timer.Simple(1, function() - if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end - if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end - end) - end - end + Beatrun_GiveGMWeapon(v) end end diff --git a/beatrun/gamemodes/beatrun/gamemode/shared.lua b/beatrun/gamemodes/beatrun/gamemode/shared.lua index 0348deb..6d89af4 100644 --- a/beatrun/gamemodes/beatrun/gamemode/shared.lua +++ b/beatrun/gamemodes/beatrun/gamemode/shared.lua @@ -1,4 +1,4 @@ -VERSION_GLOBAL = "1.0.18" +VERSION_GLOBAL = "1.0.20" VERSION_LATEST = "" VERSION_CHECKED = false diff --git a/version.txt b/version.txt index c678b02..450f88e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.18 \ No newline at end of file +1.0.20 \ No newline at end of file