I looked around the wiki for a possible example of this, basically all I see if ways to define how much ammo the gun has, or can have. I'm trying to make it so that if a user is holding a gun, and it completely runs out of ammo, (which would require the clips to be checked also) then it's automatically removed from their hands/inventory.
Thanks in advance.
I'll type something up for you, are you using both primary and secondary ammo types and clips?
Just primary
edit: thank you btw
and it's just for one weapon or for all of them?
[editline]19th July 2011[/editline]
For a single SWEP, use this at the [B]bottom[/B] of your [I]PrimaryAttack()[/I] function:
[lua]
function SWEP:PrimaryAttack()
--PRIMARY ATTACK CODE
if SERVER then
if self:Clip1() < 1 && self.Owner:GetAmmoCount(self:GetPrimaryAmmoType()) < 1 then
timer.Simple(1, function() self.Owner:StripWeapon(self:GetClass()) end) -- Delay so anim is displayed, tends to look better
return
end
end
end
[/lua]
Thank you I will test that later tonight.
[code]if wep:Clip1( ) < 1 and wep:Ammo1() < 1 and wep:Clip2( ) < 1 and wep:Ammo2( ) < 1 then
//strip weapon
end[/code]
Assuming you are working with a SWEP, Ammo1 and Ammo2 are quick ways to get the carried ammo of the weapon's type.
Sorry, you need to Log In to post a reply to this thread.