From 4d06c66bbea69dd6f0340660ff26544511ea8293 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Tue, 7 Jan 2020 13:41:16 +0100 Subject: [PATCH] Fixed weapon loading to items --- gamemode/init.lua | 2 +- plugins/plugin_addweaponsasitems.lua | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gamemode/init.lua b/gamemode/init.lua index 76eecf8..50b6dfe 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -126,9 +126,9 @@ if SERVER then MsgC( "\n" ) Quantum.Debug( "Loading plugins...") for _, file in pairs( pluginFiles ) do + Quantum.Debug( "Added plugin: " .. fol .. file ) AddCSLuaFile( fol .. file ) include( fol .. file ) - Quantum.Debug( "Added plugin: " .. fol .. file ) end else MsgC( "\n" ) diff --git a/plugins/plugin_addweaponsasitems.lua b/plugins/plugin_addweaponsasitems.lua index d123085..29f1557 100644 --- a/plugins/plugin_addweaponsasitems.lua +++ b/plugins/plugin_addweaponsasitems.lua @@ -7,12 +7,28 @@ local plugin = {} +plugin.AllowedTypes = { + ["fas2"] = true, + ["weapon"] = true, + ["quantum"] = true, + ["cw"] = true +} + function plugin.getAllWeaponID() local returnTbl = {} - for _, wep in pairs( weapons.GetList() ) do - if( wep.ClassName != "weapon_base" && wep.ClassName != "quantum_hands" && wep.ClassName != "quantum_keys" ) then -- do not want them - returnTbl[ #returnTbl + 1 ] = wep.ClassName + for _, ent in pairs( weapons.GetList() ) do + + local classname = ent.ClassName + local splitTbl = string.Split( classname, "_" ) + local entType = splitTbl[1] + + if( plugin.AllowedTypes[entType] ) then + local wep = weapons.Get( classname ) + if( classname != "weapon_base" && classname != "quantum_hands" && classname != "quantum_keys" ) then -- do not want them + returnTbl[ #returnTbl + 1 ] = classname + end end + end return returnTbl @@ -21,8 +37,9 @@ end function plugin.CreateItems( weps ) for _, wepID in pairs( weps ) do local swepTbl = weapons.Get( wepID ) + Quantum.Debug( "Added " .. wepID .. " as an item!" ) Quantum.Item.Create( wepID, { - name = swepTbl.PrintName , + name = swepTbl.PrintName, desc = swepTbl.Purpose, model = swepTbl.WorldModel, rarity = Quantum.Rarity.Common,