Effect origin problem

I’m trying to get this gun working on my TTT server: http://steamcommunity.com/sharedfiles/filedetails/?id=129257486

I used gmad to extract it and made the changes needed to get it to work in TTT but the problem is that on the secondary fire the place the effects travel to is fine but they all come from the Local player’s gun.

example: if any player uses the secondary fire he see’s it right but all the other players have the effect come from their own guns instead of his.

It is like this on all the effects so here is an example of one of them:

/effects/stridcan_charge/init.lua



local matPinch 		= Material("Effects/strider_pinch_dudv")
local matBlueFlash 	= Material("Effects/blueblackflash")
local matBlueBeam	= Material("Effects/blueblacklargebeam")


function EFFECT:Init(data)
	
	self.Shooter = data:GetEntity() //I checked and this is the right player
	self.Attachment = data:GetAttachment()
	self.WeaponEnt = self.Shooter:GetActiveWeapon()
	self.KillTime = 0
	self.ShouldRender = false
	
	if GetViewEntity() == LocalPlayer() then 
		self.ViewModel = LocalPlayer():GetViewModel()
		self.RefractScale = 0.06
		self.RefractSize = 30
		self.SpriteSize = 15
		self.BeamWidth = 4
	else
		self.ViewModel = self.WeaponEnt
		self.RefractScale = 0.16
		self.SizeScale = 1
		self.RefractSize = 280
		self.SpriteSize = 55
		self.BeamWidth = 8
	end
	
	if not self.ViewModel:IsValid() then return end	
	
	local Muzzle = 	self.ViewModel:GetAttachment(self.Attachment)
	local hitpos = self.Shooter:GetEyeTrace().HitPos
	self:SetRenderBoundsWS(Muzzle.Pos + Vector()*self.RefractSize,hitpos - Vector()*self.RefractSize)
	
	self.KillTime = CurTime() + 1.35
	self.ShouldRender = true

end


function EFFECT:Think()

	if CurTime() > self.KillTime then return false end
	if not self.Shooter then return false end
	if self.WeaponEnt ~= self.Shooter:GetActiveWeapon() then return false end
	if not self.ViewModel:IsValid() then return false end

	return true
	
end


function EFFECT:Render()

	if not self.ShouldRender then return end

	local Muzzle = 	self.ViewModel:GetAttachment(self.Attachment)
	if not Muzzle then return end
	
	local MuzzleAng = self.Shooter:GetAimVector()
	local RenderPos = Muzzle.Pos
	local hitpos = self.Shooter:GetEyeTrace().HitPos
	self:SetRenderBoundsWS(RenderPos + Vector()*self.RefractSize,hitpos - Vector()*self.RefractSize)	
	
	local invintrplt = (self.KillTime - CurTime())/1.35
	local intrplt = 1 - invintrplt
	
	render.SetMaterial(matBlueBeam)
	render.DrawBeam(RenderPos,hitpos,intrplt*self.BeamWidth,0,0,Color(255, 255, 255, intrplt*100))
	
	matPinch:SetFloat("$refractamount", math.sin(0.5*intrplt*math.pi)*self.RefractScale)
	render.SetMaterial(matPinch)
	render.UpdateRefractTexture()
	render.DrawSprite(RenderPos,self.RefractSize,self.RefractSize,Color(255,255,255,150))
	
	render.SetMaterial(matBlueFlash)
	if intrplt < 0.5 then
	
		local size = 2*self.SpriteSize*intrplt
		render.DrawSprite(RenderPos,size,size,Color(0,0,0,100))
		
	else
	
		local clr = 255*(2*intrplt - 1)
		render.DrawSprite(RenderPos,self.SpriteSize,self.SpriteSize,Color(clr,clr,clr,100))
		
	end


end


http://forum.facepunch.com/showthread.php?t=1250283

Don’t want to sound like an ass and I am really posting link to the sticky like 20 times a day, but this is getting out of control…

The effect isn’t that bad, I removed the shared.lua though so the post is less cluttered.

I might be wrong (because it’s 2AM and I am exhausted) but try changing this line:
[lua]self.ViewModel = LocalPlayer():GetViewModel()[/lua]
to
[lua]self.ViewModel = self.Owner:GetViewModel()[/lua]

errors.




[ERROR] gamemodes/terrortown/entities/effects/stridcan_charge/init.lua:15: attempt to call method 'GetViewModel' (a nil value)
  1. unknown - gamemodes/terrortown/entities/effects/stridcan_charge/init.lua:15
   2. Effect - [C]:-1
    3. unknown - gamemodes/terrortown/entities/weapons/admingun/shared.lua:143


[ERROR] gamemodes/terrortown/entities/effects/stridcan_fire/init.lua:17: attempt to call method 'GetViewModel' (a nil value)
  1. unknown - gamemodes/terrortown/entities/effects/stridcan_fire/init.lua:17


[ERROR] gamemodes/terrortown/entities/effects/stridcan_mzzlflash/init.lua:16: attempt to call method 'GetViewModel' (a nil value)
  1. unknown - gamemodes/terrortown/entities/effects/stridcan_mzzlflash/init.lua:16


[editline]22nd February 2014[/editline]

I did some debugging and this returns true if it is fired from the localplayer and if it is fired from a another person. Significant?



	if GetViewEntity() == LocalPlayer() then 
		self.ViewModel = LocalPlayer():GetViewModel()
		self.RefractScale = 0.06
		self.RefractSize = 30
		self.SpriteSize = 15
		self.BeamWidth = 4
	else
		self.ViewModel = self.WeaponEnt
		self.RefractScale = 0.16
		self.SizeScale = 1
		self.RefractSize = 280
		self.SpriteSize = 55
		self.BeamWidth = 8
	end


[editline]22nd February 2014[/editline]



        if self.Shooter:GetViewEntity() == LocalPlayer() then 
		self.ViewModel = LocalPlayer():GetViewModel()
		self.RefractScale = 0.06
		self.RefractSize = 30
		self.SpriteSize = 15
		self.BeamWidth = 4
	else
		self.ViewModel = self.WeaponEnt
		self.RefractScale = 0.16
		self.SizeScale = 1
		self.RefractSize = 280
		self.SpriteSize = 55
		self


fixed.