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]