Hey guys, I’m having a bit of trouble modifying an addon (for private use). Essentially, the original version gives a list/table of weapons that won’t be allowed to be given ammo when the box is activated. I want to reverse this function and make it so that the only weapons that are allowed to be resupplied are the ones on the list, with all others being denied. Here’s the original code. (FuckTheseGuns is the list of guns that can’t be resupplied)
function ENT:Use(activator, caller)
ammountofrandomammo = math.random(15,35)
weapon = activator:GetActiveWeapon()
if !IsValid(weapon) then return end
for p, q in pairs(FuckTheseGuns) do
if weapon:GetClass() == q then
activator:PrintMessage(HUD_PRINTTALK, "This weapon may not be resupplied with this pickup." )
activator:EmitSound("Player.DenyWeaponSelection")
return end
end
for p, q in pairs(donotgranttheseweaponsammo) do
if weapon:GetClass() == q then
activator:PrintMessage(HUD_PRINTTALK, "This weapon can't be resupplied." )
activator:EmitSound("Player.DenyWeaponSelection")
return end
end
activator:GiveAmmo( ammountofrandomammo , weapon:GetPrimaryAmmoType(), false)
activator:PrintMessage(HUD_PRINTTALK, "You picked up some ammo." )
activator:EmitSound("AmmoCrate.Open")
self:Remove()
end
end