testing random arc9 weapons

This commit is contained in:
Jonny_Bro (Nikita) 2024-11-08 21:35:11 +05:00
parent 148352596f
commit d7d9a16250
No known key found for this signature in database
GPG key ID: 3F1ECC04147E9BD8
3 changed files with 50 additions and 23 deletions

View file

@ -1,6 +1,9 @@
local vmatrixmeta = FindMetaTable("VMatrix") local vmatrixmeta = FindMetaTable("VMatrix")
local playermeta = FindMetaTable("Player") local playermeta = FindMetaTable("Player")
CreateConVar("Beatrun_RandomMWLoadouts", 0, {FCVAR_REPLICATED, FCVAR_ARCHIVE})
CreateConVar("Beatrun_RandomARC9Loadouts", 0, {FCVAR_REPLICATED, FCVAR_ARCHIVE})
BEATRUN_GAMEMODES_LOADOUTS = { BEATRUN_GAMEMODES_LOADOUTS = {
{"weapon_357", "weapon_ar2"} {"weapon_357", "weapon_ar2"}
} }
@ -86,4 +89,28 @@ function playermeta:notUsingRH(wep)
else else
return false return false
end end
end end
function getRandomMGBaseSWEP()
local allWep = weapons.GetList()
local wepIndex = math.random(#allWep)
local wep = allWep[wepIndex]
if wep.Base == "mg_base" and not wep.AdminOnly then
return wep
else
return getRandomMGBaseSWEP()
end
end
function getRandomARC9SWEP()
local allWep = weapons.GetList()
local wepIndex = math.random(#allWep)
local wep = allWep[wepIndex]
if wep.Base == "arc9_cod2019_base" and not wep.AdminOnly then
return wep
else
return getRandomARC9SWEP()
end
end

View file

@ -22,17 +22,24 @@ if SERVER then
v:Spawn() v:Spawn()
end end
if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() and not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() then
for i = 0, 1 do for i = 0, 1 do
local randomSWEP = getRandomMGBaseWeapon() local swep = getRandomMGBaseSWEP()
local w = v:Give(randomSWEP.ClassName) local w = v:Give(swep.ClassName)
timer.Simple(1, function() timer.Simple(1, function()
if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end
if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end
end) end)
end end
else 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 for _, b in ipairs(BEATRUN_GAMEMODES_LOADOUTS[math.random(#BEATRUN_GAMEMODES_LOADOUTS)]) do
local w = v:Give(b) local w = v:Give(b)

View file

@ -2,20 +2,6 @@ if SERVER then
util.AddNetworkString("Deathmatch_Start") util.AddNetworkString("Deathmatch_Start")
util.AddNetworkString("Deathmatch_Sync") util.AddNetworkString("Deathmatch_Sync")
CreateConVar("Beatrun_RandomMWLoadouts", 0, {FCVAR_REPLICATED, FCVAR_ARCHIVE})
function getRandomMGBaseWeapon()
local allWep = weapons.GetList()
local wepIndex = math.random(#allWep)
local wep = allWep[wepIndex]
if wep.Base == "mg_base" and not wep.AdminOnly then
return wep
else
return getRandomMGBaseWeapon()
end
end
function Beatrun_StartDeathmatch() function Beatrun_StartDeathmatch()
if GetGlobalBool("GM_DEATHMATCH") then return end if GetGlobalBool("GM_DEATHMATCH") then return end
if Course_Name ~= "" then return end if Course_Name ~= "" then return end
@ -31,17 +17,24 @@ if SERVER then
v:Spawn() v:Spawn()
end end
if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() and not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() then
for i = 0, 1 do for i = 0, 1 do
local randomSWEP = getRandomMGBaseWeapon() local swep = getRandomMGBaseSWEP()
local w = v:Give(randomSWEP.ClassName) local w = v:Give(swep.ClassName)
timer.Simple(1, function() timer.Simple(1, function()
if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end if w:GetPrimaryAmmoType() ~= -1 then v:GiveAmmo(10000, w:GetPrimaryAmmoType(), true) end
if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end if w:GetSecondaryAmmoType() ~= -1 then v:GiveAmmo(5, w:GetSecondaryAmmoType(), true) end
end) end)
end end
else 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 for _, b in ipairs(BEATRUN_GAMEMODES_LOADOUTS[math.random(#BEATRUN_GAMEMODES_LOADOUTS)]) do
local w = v:Give(b) local w = v:Give(b)