I have been having a hard time figuring out this command. When the primary clip is 0 I want the gun to be stripped from the player.
[lua]function SWEP:CanPrimaryAttack()
if self.Weapon:Clip1() <= 0 then
self:EmitSound( "Weapon_Shotgun.Empty" )
self.Owner:StripWeapon("weapon_ttt_dhook")
end
end[/lua]
[QUOTE=Thetomm2010;41389217]I have been having a hard time figuring out this command. When the primary clip is 0 I want the gun to be stripped from the player.
[lua]function SWEP:CanPrimaryAttack()
if self.Weapon:Clip1() <= 0 then
self:EmitSound( "Weapon_Shotgun.Empty" )
self.Owner:StripWeapon("weapon_ttt_dhook")
end
end[/lua][/QUOTE]
Try
[lua]function SWEP:CanPrimaryAttack()
if self.Weapon:Clip1() <= 0 then
self:EmitSound( "Weapon_Shotgun.Empty" )
self.Owner:StripWeapon(self.Weapon:GetClass())
end
end[/lua]
self.Weapon is obsolete, use self.
hmmm well still cant seem to get it right I have tried
[lua]function SWEP:CanPrimaryAttack()
if self.Weapon:Clip1() <= 0 then
self:EmitSound( "Weapon_Shotgun.Empty" )
self.Owner:StripWeapon(self.Weapon:GetClass())
end
end[/lua]
That didn't work so I tried this and still no good the gun doesn't even make the click when it runs out of ammo. There has to be something simple that I am just missing.
this is what Ive come up with so far not much diffrent and yes I tied my original code with just self.
[lua]function SWEP:CanPrimaryAttack()
if self.Clip1() <= 0 then
self:EmitSound( "Weapon_Shotgun.Empty" )
self.Owner:StripWeapon("weapon_ttt_dhook")
return false
end
return true
end[/lua]
[editline]12th July 2013[/editline]
GOT IT!!!!! Here if anyone wants it too.
[lua]self:TakePrimaryAmmo(1)
if self:Clip1() == 0 then
self:Remove()
end[/lua]
Sorry, you need to Log In to post a reply to this thread.