Bullet Shells

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…

[lua]
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
[/lua]

Easy, right?

**Get it!


UPDATED! The shells now use the gmod_silent surface properties (only in gmod beta).

**

http://www.garrysmod.org/img/?t=dll&id=77827

Please give credit where due if you use this in a weapon base you’re releasing, etc.

Where do you need to put the file ?

Put the effects folder in garrysmod/garrysmod/lua.

Keep in mind that this won’t work like you think it will, though. It’s an effect, so if you want to make it work, you’ll have to add it into the swep script so that the weapon uses it. Shouldn’t be too hard.

I just did but no ejecting shells.

it’s an effect, it goes in the effects folder.

I didn’t make it in addon format because it’s not usable on its own. If you aren’t making SWEPs with this then i suggest you don’t bother with it.

That’s alright. I’ll probably mod the default CS:S SWEPs to use the effect for my own usage.

I love you.

Ive been looking for some thing like this for a long time

So how do i make it work whit a swep?
Note: I used the weapon_cs_base and the sweps are in my gamemode.

And i suck at coding i used a tutorial and gmod wiki to make a gamemode

If you can’t figure out how this works by reading the OP then i suggest you learn some basics first.

I could use this for the FortwarsX weapons. But I thought the shell effects were already included in Gmod…

Oh I never noticed that the CSS guns hadn’t shells.

HL2 weapons do them by default but not CS:S weapons.

[editline]08:04PM[/editline]

Also, i added a “gmod_silent” physics material in gmod beta, so now the shells don’t play the plastic impact sounds. :w00t:

Well instead of being a jackass you could just tell me where to put everything?! huh?
just cuz you are a pro at lua doesn’t mean that being a dick against the ppl that are noobs at scripting.
Isn’t that right? I tried adding the shit in weapon_cs_base and i did not work. So can you PLEASE tell me where to put it?! thanks

If you read the shit in the lua tags in the OP you’d know exactly what to do. It’s all commented nicely and everything.

If you can’t understand that then i suggest you go read some tutorials or something. I’m not here to teach you Lua from the ground up.

LOL. Pwned. Also, the add-on sounds interesting :smiley:

why don’t you use the built-in bullet emitting effects

I didn’t know any existed and tbh it was more fun to make my own.

Look the code that you wrote it doesn’t show up. It shows up when loading the page and then disapears. So i cant read it. There. Can you tell me where to put? I cant read the text in OP cuz it does not show up.
Facepunch has always been fucked on my computer lawl

Ok i got the OP to work somehow. Dunno how. And i did what it says but i dont know where to put
SHELL_9MM = 1
SHELL_57 = 2
and so on…

Where does it go?

I would suggest you go learn the basics of lua before trying to do anything.
Just open the damn lua file, and read the comments, or go do something else.

Why are you all guys such dicks?
“Learn lua”
“noob”

i mean comon. I know basic lua. So instead of being a dick you could tell me where i put the
SHELL_9MM = 1
SHELL_57 = 2
SHELL_556 = 3
SHELL_762NATO = 4
SHELL_SHOTGUN = 5
SHELL_338MAG = 6
SHELL_50CAL = 7

Is it so fung hard to just tell me where it goes!?!?!?!? Is it?!
Just cuz you are pros on coding doesn’t mean that i am! I am new on lua. Give me a fu
ng break FFS!!