Weapon firing twice or doing double damage

For some reason my weapon does double it’s set damage. The print line that I have prints twice so I know it’s getting called twice, my guess is once by the client and once by the server. Although nothing else in the firing function doubles(sounds, animations, ect) except the damage of the bullet which is set to 50 but deals 100. Although it is being called by the client and server it shouldn’t do double the damage right? That would mean you can go around running your clientside script shooting people with your invisible gun.

shared.lua
[lua]
SWEP.Primary.Recoil = 1
SWEP.Primary.Damage = 50
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0.015

function SWEP:PrimaryAttack()
if IsFirstTimePredicted() then
self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
self.Weapon:EmitSound(self.Primary.Sound)
self:MiscFunc()
end
end

function SWEP:MiscFunc()
self:ZEShootBullet(self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone)
end

function SWEP:ZEShootBullet(dmg, recoil, numbul, cone)
numbul = numbul || 1
cone = cone || 0.01

local bullet 	= {}
bullet.Num  	= numbul
bullet.Src 		= self.Owner:GetShootPos()
bullet.Dir 		= self.Owner:GetAimVector()
bullet.Spread 	= Vector(cone, cone, 0)
bullet.Tracer 	= 1
bullet.Force 	= 10 * dmg
bullet.Damage 	= dmg

print(bullet.Damage) --prints 50

self.Owner:FireBullets(bullet)
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self.Owner:MuzzleFlash()

self.Owner:SetAnimation(PLAYER_ATTACK1)

end
[/lua]

I have tried the things below as well with no success.

[lua]
if (SERVER) then
self.Owner:FireBullets(bullet)
end

if (SERVER) then
if IsFirstTimePredicted() then
self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
self.Weapon:EmitSound(self.Primary.Sound)
self:MiscFunc()
end
end
[/lua]

Try using…

if CLIENT then return end

in the primary attack.

Did you not read what I said?

find me, I think it’s because you’re trying it in single player, where the client’s actions do have an effect. Try it on a server.

It’s multiplayer tested with a friend.

It’s not firing twice. There’s an odd … thing that means weapons do twice the damage you set. I’m not sure whether it is caused by the gamemode hook GM:ScalePlayerDamage, but that hook does provide a quick solution if you want the damage amount you put in to be accurately reflected when the weapon damages someone:

[lua]function ScaleDamage (ply, hitgroup, dmginfo)
dmginfo:AddDamage (-dmginfo:GetBaseDamage())
end

hook.Add (“ScalePlayerDamage”,“ScaleDamageFix”,ScaleDamageFix)[/lua]

(done from memory, should work though)

Theoretically it shouldn’t screw with greater damage on headshots, etc. but I can’t remember if it does. If you want to save all this hassle you could just put half the damage on the bullets you are firing.

Ok thanks for that, could anyone else confirm this? I will do what you suggested and just put half the damage of what I want to fix it.