Hey I hope this isn't the wrong place to post this but I need some help. If this isn't relevant just remove this post. On to the issue.
I have some code here to change how max ammo is handled (borrowed from the wonderweapons pack on the workshop) and pap function for the m1911 from Mac_Tonight's pack.
-- Nzombies stuff
SWEP.DisableChambering = true --Prevents TFA weapon chambering
SWEP.Primary.MaxAmmo = 80 -- Sets primary ammo of the swep
-- Max Ammo function
function SWEP:NZMaxAmmo() --max ammo function, called when a weapon is bought from the wall (or refilled), box, or pack a punched
if SERVER then
self.Owner:SetAmmo( self.Primary.MaxAmmo, self.Primary.Ammo ) -- Sets the ammo reserve to the primary ammo's max
end
end
-- PaP Function
function SWEP:OnPaP() -- Pack a Punch function, called when the weapon is pack a punched
self.Primary.Damage = 300 -- Damage of the weapon after PaP
self.Primary.ClipSize = 8 -- Clipsize of the weapon after PaP
self.Primary.MaxAmmo = 80 -- Max ammo of the weapon after PaP
self:ClearStatCache() -- Clears the stat cache of the held TFA weapon (Necessary for live magazine and ammo changes)
return true -- Return true to make sure the PaP function runs.
end
The issue I run into is on spawn and for the first weapon buy. The starting weapon cannot receive ammo under any circumstances and starts with no reserve ammo. The first weapon you buy from the wall/box also starts with no reserve ammo. If someone could point me in the right direction that would be awesome.
The starting weapon issue only happens after the first game of a session. I'm at a loss as I don't know much lua and I can't for the life of me figure out what the issue is as the game isn't throwing an error out.
TLDR: I need to set reserve ammo on a weapon as I buy it/spawn with it.
Hey I hope this isn't the wrong place to post this but I need some help. If this isn't relevant just remove this post. On to the issue.
I have some code here to change how max ammo is handled (borrowed from the wonderweapons pack on the workshop) and pap function for the m1911 from Mac_Tonight's pack.
The issue I run into is on spawn and for the first weapon buy. The starting weapon cannot receive ammo under any circumstances and starts with no reserve ammo. The first weapon you buy from the wall/box also starts with no reserve ammo. If someone could point me in the right direction that would be awesome.
The starting weapon issue only happens after the first game of a session. I'm at a loss as I don't know much lua and I can't for the life of me figure out what the issue is as the game isn't throwing an error out.
TLDR: I need to set reserve ammo on a weapon as I buy it/spawn with it.
EDIT: Added comments to the code.