@name 
@inputs 
@outputs 
@persist 
@trigger 
//Give weapon and ammo
e2function entity entity:giveWep(string weapon)
	if (!validEntity(this)) then return end
	
	local owner = self.player
	
	if (owner:IsAdmin() and this:IsPlayer()) then
		this:StripWeapon(weapon)
		return this:Give(weapon)
	end
	
	return
end

e2function entity entity:giveWep(string weapon, number amount)
	if (!validEntity(this)) then return end
	
	local owner = self.player
	
	if (owner:IsAdmin() and this:IsPlayer()) then
		this:StripWeapon(weapon)
		weaponEnt = this:Give(weapon)
		if (weaponEnt:IsValid()) then
			ammo = weaponEnt:GetPrimaryAmmoType()
			this:SetAmmo(amount, ammo)
			
			return weaponEnt
		end
	end
	
	return
end

e2function string entity:giveAmmo(number amount, string ammo)
	if (!validEntity(this)) then return "" end
	
	local owner = self.player
	
	if (owner:IsAdmin() and this:IsPayer()) then
		this:GiveAmmo(amount, ammo)
		
		return amount .. " " .. ammo
	end
	
	return ""
end

//Set ammo, health and armor
e2function string entity:setAmmo(number amount, string ammo)
	if (!validEntity(this)) then return "" end
	
	local owner = self.player
	
	if (owner:IsAdmin() and this:IsPlayer()) then
		this:SetAmmo(amount, ammo)
		
		return amount .. " " .. ammo
	end
	
	return ""
end

e2function string entity:setHealth(number amount)
	if (!validEntity(this)) then return "" end
	
	local owner = self.player
	
	if (owner:IsAdmin() and this:IsPlayer()) then
		this:SetHealth(amount)
		
		return amount
	end
	
	return ""
end

e2function string entity:setArmor(number amount)
	if (!validEntity(this)) then return "" end
	
	local owner = self.player
	
	if (owner:IsAdmin() and this:IsPlayer()) then
		this:SetArmor(amount)
		
		return amount
	end
	
	return ""
end

//Strip weapon and ammo
e2function number entity:stripWep()
	if (!validEntity(this)) then return 0 end
	
	local owner = self.player
	
	if ((owner:IsAdmin() or owner == this) and this:IsPlayer()) then
		this:StripAmmo()
		this:StripWeapons()
		
		return 1
	end
	
	return 0
end

e2function number entity:stripWep(string weapon)
	if (!validEntity(this)) then return 0 end
	
	local owner = self.player
	
	if ((owner:IsAdmin() or owner == this) and this:IsPlayer()) then
		this:StripWeapon(weapon)
		
		return 1
	end
	
	return 0
end

e2function number entity:stripAmmo()
	if (!validEntity(this)) then return 0 end
	
	local owner = self.player
	
	if ((owner:IsAdmin() or owner == this) and this:IsPlayer()) then
		this:StripAmmo()
		
		return 1
	end
	
	return 0
end

//has weapon?
e2function number entity:hasWeapon(string weapon)
	if (!validEntity(this)) then return 0 end
	
	local owner = self.player
	
	if (this:IsPlayer()) then
		return this:HasWeapon(weapon)
	end
	
	return 0
end
