local vm, att, effect
vm = self.Owner:GetViewModel( )
att = vm:LookupAttachment( self.MuzzleAttachment ) --Or whatever it was
util.ParticleTracerEx(
"bullet_tracer01",
self.Owner:GetShootPos( ),
self.Owner:GetShootPos( ) + self.Owner:GetAimVector( ) * 4096,
vm:EntIndex( ),
att )
the attachment is Muzzle, i have checked the model viewr, andi ts correct, but the tracers seem to be coming from the middle of the screen, not the gun, Any help?
Are you doing this serverside? If so, try doing it clientside, the predicted serverside viewmodel is really unaccurate and you will be unable to get its attachments.
Also, EntIndex? I always thought you had to give it the entity directly, that may explain why my TF2 tracers are screwed off and come from the map origin.
/*---------------------------------------------------------
ShootBullet
---------------------------------------------------------*/
function SWEP:CSShootBullet(dmg, recoil, numbul, cone)
numbul = numbul or 1
cone = cone or 0.01
local bullet = {}
bullet.Num = numbul
bullet.Src = self.Owner:GetShootPos() -- Source
bullet.Dir = self.Owner:GetAimVector() -- Dir of bullet
bullet.Spread = Vector(cone, cone, 0) -- Aim Cone
bullet.Tracer = 0 -- Show a tracer on every x bullets
bullet.Force = 0.5 * dmg -- Amount of force to give to phys objects
bullet.Damage = dmg -- Amount of damage to give to the bullets
bullet.Callback = HitImpact
-- bullet.Callback = function ( a, b, c ) BulletPenetration( 0, a, b, c ) end -- CALL THE FUNCTION BULLETPENETRATION
self.Owner:FireBullets(bullet) -- Fire the bullets
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation(PLAYER_ATTACK1) -- 3rd Person Animation
local vm, att, effect
vm = self.Owner:GetViewModel( )
att = vm:LookupAttachment( self.MuzzleAttachment ) --Or whatever it was
util.ParticleTracerEx(
"bullet_tracer01",
self.Owner:GetShootPos( ),
self.Owner:GetShootPos( ) + self.Owner:GetAimVector( ) * 4096,
vm:EntIndex( ),
att )
its jsut in shared.lua so im guessing serverside yeah.
Yep, that’s serverside. Just make an usermessage hook clientside, and call it serverside. You’ll need to send the name of the tracer, and the hit position, that’s all.
Basically, you should use usermessages whenever the server needs to make the client do something. You can see it as calling a clientside function from the server. Use it wisely though, you shouldn’t send a shitload of data all the time if you don’t want your gamemode (or SWEP, or whatever) to be lagtastic.
Here, all the client really needs to know is the name of the tracer effect, and the hit position of your bullet. The start position is obviously calculated from the local player’s viewmodel.
It’s unnecessary to send the name of the tracer if you’re only going to be using one kind of tracer. The other thing is that you shouldn’t be using usermessages to handle events like guns firing, because that means you are not using proper clientside prediction, and not having prediction is very noticeable to and annoying for the player.