This is an effect (it goes in the effects folder) for weapon models that makes them eject shells. Depending on the weapon model, you might need to change the attachment name. All the CS:S weapons use “2” as their shell eject position.
This effect covers every bullet type in CS:S and also has appropriate sounds for each.
Here’s how you’d use it in a typical SWEP…
SHELL_9MM = 1 – pistol shells
SHELL_57 = 2 – bigger pistol shells? maybe for desert eagle or SMGs?
SHELL_556 = 3 – AK47, etc. shells
SHELL_762NATO = 4 – M4, etc. shells
SHELL_SHOTGUN = 5 – all shotguns
SHELL_338MAG = 6 – AWP/scout shells
SHELL_50CAL = 7 – this is the default hl2 rifle shell. it looks roughly like a 50 caliber shell.
– these are the different types of bullets you can use
– this would be done in the base swep or wherever you store enums
SWEP.Primary.ShellType = SHELL_9MM
– what kind of shells does your weapon use?
– this would go in each individual SWEP.
local ed = EffectData()
ed:SetEntity( self.Weapon )
ed:SetAttachment( self.Weapon:LookupAttachment( “2” ) ) – what attachment should the bullet come from?
ed:SetScale( self.Primary.ShellType )
util.Effect( “weapon_shell”, ed, true, true )
– this would be called on the server in the primary fire function somewhere
UPDATED! The shells now use the gmod_silent surface properties (only in gmod beta).
Please give credit where due if you use this in a weapon base you’re releasing, etc.