Dry fire help...

Greetings! I basically wanna hear that dry fire ‘click’ sound when the magazine of my SWEP is empty, but I don’t know what to type as code in order to display it. Already disabled automatic reloading but now I’m missing this little detail which would make my experience a bit more realistic. Hoping for a soon answer, thank you very much guys ;D

If your ammo is less than or equal to 0, play the ‘click’ sound and trigger a reload (or don’t reload, it’s up to you). The base weapon takes care of it in CanPrimaryAttack, like this

[lua]function SWEP:CanPrimaryAttack()

if ( self.Weapon:Clip1() <= 0 ) then

    self:EmitSound( "Weapon_Pistol.Empty" )
    self:SetNextPrimaryFire( CurTime() + 0.2 )
    self:Reload()
    return false

end

return true 

end[/lua]

When I put that code not only I don’t get the empty sound, my clip ammo also gets unlimited and that’s not what I want :frowning:

Don’t just copy and paste it unchanged, work it into the appropriate part of your code.

I’ve tried several stuff like changing ‘true’ for ‘false’, ‘false’ for ‘true’ and sound name but nothing works. Any ideas on what more I could do?

Post the code you have.

Nvm, just managed to make it work somehow. Thank you all for your attention :slight_smile: