How to add custom particles as a muzzleflash or smoke to a swep?

Yea. I’m struggling to know how to do such things. I looked everywhere and I’m just lost. What I’m really trying to do is make the leeroy’s particles from his base to function properly with modern gmod sweps.

I would really appreciate your help. Thanks.

It depends on whether those new effects you are trying to use a Lua effects or Orange Box particles effects (.pcf)

In short, you want to disable the default muzzle flash, but not calling Player:MuzzleFlash() and http://wiki.garrysmod.com/page/WEAPON/FireAnimationEvent.

Next you will want to create your effect and position it on the view model if player is in first person mode, or on worldmodel if the player is in third person mode.

You disable the muzzleflash and stuff at where? the autorun or somewhere else?

btw I’m using .pcf files for the particles

At the weapon, obviously.

For .pcf, use

or

I don’t really get what it says. Mainly on the attachment id. If you can, could you show me an example?

I don’t have the effect, so no. I am pretty sure attachment id should be 1.

Alright thanks.

What I got so far :


ParticleEffectAttach( string lee_particle, number:attachType( ), Entity:MuzzleFlash( ), number 1 )

I got a error saying :


[ERROR] addons/pspak_expansion/lua/effects/pspak_muzzle_effect/init.lua:33: ')' expected near 'lee_particle'
  1. unknown - addons/pspak_expansion/lua/effects/pspak_muzzle_effect/init.lua:0

Also, for some reason the particle won’t initialize :I

Code for the particle initialization :


hook.Add( "Initialize", "Initialize particles/lee_particle.pcf", function()
   AddCSLuaFile()
   game.AddParticles("particles/lee_particle.pcf")
   PrecacheParticleSystem("muzzle_lee_rg")
   PrecacheParticleSystem("muzzle_lee_pistol")
   PrecacheParticleSystem("muzzle_lee_simple_pistol")
   PrecacheParticleSystem("muzzle_lee_rifle")
   PrecacheParticleSystem("muzzle_lee_shotgun")
   PrecacheParticleSystem("muzzle_lee_silenced")
   PrecacheParticleSystem("muzzle_lee_sniper")
end)

hook.Add( "Initialize", "Initialize particles/muzzle_smoke.pcf", function()
   AddCSLuaFile()
   game.AddParticles("particles/muzzle_smoke.pcf")
   PrecacheParticleSystem("muzzle_smoke_trail")
   PrecacheParticleSystem("muzzle_simple_silenced")
   PrecacheParticleSystem("muzzle_sparks_pistol")
   PrecacheParticleSystem("muzzle_smoke")
   PrecacheParticleSystem("3D_Smoke_Trail")
end)

ParticleEffectAttach( “muzzle_lee_rifle”, PATTACH_POINT_FOLLOW, self, 1 )

It seems to me that you have not a slightest idea of what you are doing. Visit this link:
http://www.facepunch.com/showthread.php?t=1337945

And learn the language you work with before using it.

Ok. Well I really want to know what is causing the problem with the particle initialization. I’m already looking through the GLua Docs for solutions. But if you can find a fix, I’ll be a happy man.

Remove all of those function calls outside of the Initialize hook, it is not necessary. And you failed to tell what’s wrong with them. “Doesn’t work/initialize” is not helpful.