Added logic_stripweapons entity

Specific entity to remove a weapon that targets a player activator
holds:

--keys--
keepfists: If yes, the stripallweapons input strips all weapons but
fists

--Inputs--
stripweapon: Strips a single weapon as mentioned in arguments
stripallweapons: Strips all weapons the activator has
setkeepfists: If 1 the stripallweapons inputs strip all weapons but
fists
This commit is contained in:
Ben 2014-12-15 18:55:23 +00:00
parent 6744b6cce0
commit 3e23a89326

View file

@ -0,0 +1,36 @@
ENT.Type = "point"
function ENT:Initialize()
self.KeepFists = self.KeepFists or 1
end
function ENT:AcceptInput(name, activator, caller, args)
name = string.lower(name)
if name == "stripweapon" then
if activator:IsPlayer() and activator:Alive() and activator:Team() == TEAM_HUMAN then
activator:StripWeapon(args)
end
elseif name == "stripallweapons" then
if activator:IsPlayer() and activator:Alive() and activator:Team() == TEAM_HUMAN then
if tonumber(self.KeepFists) == 1 then
local weps = activator:GetWeapons()
for k, v in pairs(weps) do
local weaponclass = v:GetClass()
if weaponclass ~= "weapon_zs_fists" then activator:StripWeapon(weaponclass) end
end
else
activator:StripWeapons(args)
end
end
elseif name == "setkeepfists" then
self.KeepFists = tonumber(args)
end
end
function ENT:KeyValue(key, value)
key = string.lower(key)
if key == "keepfists" then
self.KeepFists = tonumber(value)
end
end