Files
wnsrc/lua/arccw/client/cl_npc.lua
lifestorm 9c918c46e5 Upload
2024-08-04 23:12:27 +03:00

41 lines
1.2 KiB
Lua

--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
hook.Add("PopulateMenuBar", "ArcCW_NPCWeaponMenu", function (menubar)
local menu = menubar:AddOrGetMenu("ArcCW NPC Weapons")
menu:AddCVar("None", "gmod_npcweapon", "none")
menu:AddSpacer()
local weaponlist = weapons.GetList()
table.SortByMember(weaponlist, "PrintName", true)
local cats = {}
for _, k in pairs(weaponlist) do
if weapons.IsBasedOn(k.ClassName, "arccw_base") and !k.NotForNPCs and !k.PrimaryBash and k.Spawnable then
local cat = k.Category or "Other"
if !cats[cat] then cats[cat] = menu:AddSubMenu(cat) end
cats[cat]:SetDeleteSelf(false)
cats[cat]:AddCVar(k.PrintName, "gmod_npcweapon", k.ClassName)
end
end
end)
net.Receive("arccw_npcgiverequest", function(len, ply)
local class = GetConVar("gmod_npcweapon"):GetString()
net.Start("arccw_npcgivereturn")
net.WriteString(class)
net.SendToServer()
end)