function SWEP:SecondaryAttack()
self:SetNextSecondaryFire( CurTime() + 20 )
if ( self:Clip1() < 150 and self.Owner:Armor() < 300 ) then
self.Owner:EmitSound(Sound("weapons/laser_cannon/suit/cant_charge.wav"))
return end
if self.Owner:Armor() < 300 then
self.Owner:SetArmor(300)
self.Owner:EmitSound(Sound("weapons/laser_cannon/suit/suitcharge.wav"))
self:TakePrimaryAmmo(150)
end
return true
end
[ERROR] addons/fresh_memes/lua/weapons/weapon_sound_gun_07/shared.lua:156: attempt to call method 'SetArmor' (a nil value)
1. unknown - addons/fresh_memes/lua/weapons/weapon_sound_gun_07/shared.lua:156
SetArmor is serverside only, you're calling it shared.
You might want to make sure the owner is valid and a player too because only players have armor functions.
It still gives me the armor, but creates a clientside error which is just kind of annoying, but I don't know how else to do it. I've seen other weapons with armor setting functions in their shared.lua file, but they don't make any errors for some reason.
Use a server side check before running the function (if (SERVER) then)
How would that help me? Wouldn't that make it so it never runs?
[QUOTE=VORTEX Gaming;52238866]How would that help me? Wouldn't that make it so it never runs?[/QUOTE]
shared.lua runs on client and server, so it means code within the if statement won't run clientside
Oh. Thank you. I guess I agree with the results at the top lmao
Sorry, you need to Log In to post a reply to this thread.