Hey Facepunch, so I'm currently working on a SWEP, and I want it to have 2 muzzleflash particles.
One seen in firstperson (viewmodel), the other only visible in thirdperson (worldmodel).
Under my PrimaryAttack function:
[lua]local vm = self.Owner:GetViewModel()
ParticleEffectAttach("muzzleflash",PATTACH_POINT_FOLLOW,vm,1)
ParticleEffectAttach("muzzleflash",PATTACH_POINT_FOLLOW,self.Weapon,1)[/lua]
In thirdperson, only the worldmodel muzzleflash particle is visible.
But in firstperson, both the viewmodel [b]AND[/b] the worldmodel particles are visible.
How can I fix it so that the worldmodel particle isn't rendered in firstperson?
I've toyed around a bit with "self.Owner:ShouldDrawLocalPlayer()" but couldn't figure it out, any advice? :smile:
Only call the particle function on the weapon itself if self.Owner:ShouldDrawLocalPlayer() is true, and only apply it on the view model if self.Owner:ShouldDrawLocalPlayer() is false.
You can also use self.Owner:GetViewEntity() checks
[QUOTE=Robotboy655;51978259]Only call the particle function on the weapon itself if self.Owner:ShouldDrawLocalPlayer() is true, and only apply it on the view model if self.Owner:ShouldDrawLocalPlayer() is false.
You can also use self.Owner:GetViewEntity() checks[/QUOTE]
Thanks for the response Rubat!
I tried your first suggestion:
[lua]if self.Owner:ShouldDrawLocalPlayer() == false then
ParticleEffectAttach("muzzleflash",PATTACH_POINT_FOLLOW,vm,1) else
ParticleEffectAttach("muzzleflash",PATTACH_POINT_FOLLOW,self.Weapon,1)
end[/lua]
But I get a lua error in console:
[code]attempt to call method 'ShouldDrawLocalPlayer' (a nil value)[/code]
I tried wrapping the code in an "if CLIENT then" statemant as I found that ShouldDrawLocalPlayer is clientside only, but then the particles didn't appear (It fixed the error though).
Perhaps I'm missing something?
bump
You shouldn't be firing particles from the server. You could compare GetViewEntity of the weapon's owner. But this won't cover 3rd person view scripts that don't set your view entity as something other than yourself.
Sorry, you need to Log In to post a reply to this thread.