Why my effects work in singleplayer but not in multiplayer?
5 replies, posted
[b]Objective: [/b]I'm trying to get my effects appear in multiplayer. They work perfectly fine on singleplayer but in multiplayer, I can't even see my bullets or bullet holes.
[b]Error: [/b]Effects don't appear in multiplayer at all.
[b]Code: [/b] [lua]
--SHARED.LUA
function SWEP:PrimaryAttack()
if (self.Weapon:CanPrimaryAttack() != true) then return end
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Weapon:EmitSound( ShootSound )
self.Weapon:SetNextPrimaryFire( CurTime() + GetConVarNumber(tostring("frugle_smgreload")))
bullet = {}
bullet.Src = self.Owner:GetShootPos()
bullet.Attacker = self.Owner
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0.03,0.03,0.03)
bullet.Num = 1
bullet.Damage = math.random(2,5)
bullet.Force = 3
bullet.Tracer = 1
bullet.TracerName = "Tracer"
bullet.Callback = function( attacker, tr, dmginfo )
local tr = self.Owner:GetEyeTrace()
local effectdata = EffectData()
effectdata:SetStart(tr.HitPos)
effectdata:SetOrigin( tr.HitPos )
effectdata:SetScale( 1 )
effectdata:SetNormal( tr.HitNormal )
effectdata:SetMagnitude( 4 )
effectdata:SetRadius( 8 )
util.Effect("cball_bounce", effectdata)
end
if (!SERVER) then return end
self.Owner:FireBullets( bullet )
self.Weapon:TakePrimaryAmmo(1)
end[/lua]
[b]Notes: [/b]Help is greatly appreciated
I've tried to do it like it's done on manhack gun but it still doesn't work :(
Automerge didn't work...
Anyway here two screenshots if that helps.
Singleplayer:
[img]http://dl.dropbox.com/u/99834/gmodwepon/splayer.png[/img]
Multiplayer:
[img]http://dl.dropbox.com/u/99834/gmodwepon/mplayer.png[/img]
You need to put
[lua]if (!SERVER) then return end[/lua]
below
[lua]self.Owner:FireBullets( bullet )[/lua]
Calling FireBullets on the client is what allows it to render the tracers and other clientside effects related to the bullets.
Thanks but that didn't work :(
Of course I removed it.
[editline]06:00PM[/editline]
and put it below
EDIT: I finally got it working!
I changed
[lua]if (self.Weapon:CanPrimaryAttack() != true) then return end[/lua]
to
[lua]if (self.Weapon:CanPrimaryAttack() == false) then return end[/lua]
No idea why it started working after that.
Sorry, you need to Log In to post a reply to this thread.