TTT M9k weapon ammo problem

Hey!
So I’m trying to convert a weapon from M9k base to work with weapon_tttbase and I managed to get everything other than ammo working.

So my problem is that when I pick up the weapon it has 30 ammo in the clip and 30 left and if I shoot some bullets, drop it and pick it back up it gets reset to 30 in the clip and 30 left outside. Even if I pick up more ammo to make it 30/60 after pick up it resets back to 30/30.

Here’s the code for the weapon (Sorry about the mess, I’m just trying to get it to work not to clean it)
[lua]
– Variables that are used on both client and server
SWEP.Gun = (“bb_famas_alt”) – must be the name of your swep
SWEP.Category = “CS:S Weapons”
SWEP.Author = “”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.Instructions = “”
SWEP.MuzzleAttachment = “1” – Should be “1” for CSS models or “muzzle” for hl2 models
SWEP.ShellEjectAttachment = “2” – Should be “2” for CSS models or “1” for hl2 models
SWEP.PrintName = “FAMAS” – Weapon name (Shown on HUD)
SWEP.Slot = 2 – Slot in the weapon selection menu
SWEP.SlotPos = 154 – Position in the slot
SWEP.DrawAmmo = true – Should draw the default HL2 ammo counter
SWEP.DrawWeaponInfoBox = false – Should draw the weapon info box
SWEP.BounceWeaponIcon = false – Should the weapon icon bounce?
SWEP.DrawCrosshair = false – set false if you want no crosshair
SWEP.Weight = 30 – rank relative ot other weapons. bigger is better
SWEP.AutoSwitchTo = true – Auto switch to if we pick it up
SWEP.AutoSwitchFrom = true – Auto switch from if you pick up a better weapon
SWEP.HoldType = “ar2” – how others view you carrying the weapon

SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.ViewModel = “models/weapons/2_rif_famas.mdl” – Weapon view model
SWEP.WorldModel = “models/weapons/3_rif_famas.mdl” – Weapon world model
SWEP.Base = “weapon_tttbase”
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.FiresUnderwater = false

SWEP.Kind = WEAPON_HEAVY
SWEP.AmmoEnt = “item_ammo_smg1_ttt”
SWEP.AutoSpawnable = true
3
SWEP.Primary.Ammo = “SMG1”
SWEP.Primary.Delay = 0.08
SWEP.Primary.Recoil = 0.8
SWEP.Primary.Cone = 0.07
SWEP.Primary.Damage = 17
SWEP.Primary.Automatic = true
SWEP.Primary.ClipSize = 30
SWEP.Primary.ClipMax = 60
SWEP.Primary.DefaultClip = 30

SWEP.Primary.Sound = Sound(“Alt_Weapon_FAMAS.1”) – Script that calls the primary fire sound
SWEP.Primary.RPM = 950 – This is in Rounds Per Minute
SWEP.Primary.KickUp = 0.3 – Maximum up recoil (rise)
SWEP.Primary.KickDown = 0.3 – Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal = 0.3 – Maximum up recoil (stock)
SWEP.Primary.Automatic = true – Automatic = true; Semi Auto = false
SWEP.Primary.Ammo = “SMG1”

SWEP.Secondary.IronFOV = 55 – How much you ‘zoom’ in. Less is more!

SWEP.data = {} --The starting firemode
SWEP.data.ironsights = 1

SWEP.Primary.NumShots = 1 – How many bullets to shoot per trigger pull
SWEP.Primary.Spread = .025 – Define from-the-hip accuracy 1 is terrible, .0001 is exact)
SWEP.Primary.IronAccuracy = .015 – Ironsight accuracy, should be the same for shotguns
SWEP.SelectiveFire = true

– Enter iron sight info and bone mod info below

SWEP.IronSightsPos = Vector(-2.844, -4.713, 3.188)
SWEP.IronSightsAng = Vector(0.384, 0.451, 0)
SWEP.SightsPos = Vector(-2.813, -0.713, 1.154)
SWEP.SightsAng = Vector(0.384, 0.451, 0)
SWEP.RunSightsPos = Vector(5.906, -3.386, 2.44)
SWEP.RunSightsAng = Vector(-18.466, 64.212, 0)

– Picked up by player. Transfer of stored ammo and such.
function SWEP:Equip(newowner)
if SERVER then
if self:IsOnFire() then
self:Extinguish()
end

  self.fingerprints = self.fingerprints or {}

  if not table.HasValue(self.fingerprints, newowner) then
     table.insert(self.fingerprints, newowner)
  end

  if self:HasSpawnFlags(SF_WEAPON_START_CONSTRAINED) then
     -- If this weapon started constrained, unset that spawnflag, or the
     -- weapon will be re-constrained and float
     local flags = self:GetSpawnFlags()
     local newflags = bit.band(flags, bit.bnot(SF_WEAPON_START_CONSTRAINED))
     self:SetKeyValue("spawnflags", newflags)
  end

end

if SERVER and IsValid(newowner) and self.StoredAmmo > 0 and self.Primary.Ammo != “none” then
local ammo = newowner:GetAmmoCount(self.Primary.Ammo)
local given = math.min(self.StoredAmmo, self.Primary.ClipMax - ammo)

  newowner:GiveAmmo( given, self.Primary.Ammo)
  self.StoredAmmo = 0

end
end

if CLIENT then
function SWEP:DrawHUD()
if self:GetIronsights() then
surface.SetDrawColor( 0, 0, 0, 255 )

     local x = ScrW() / 2.0
     local y = ScrH() / 2.0
     local scope_size = ScrH()

                    surface.SetDrawColor(0, 0, 0, 255)


  else
     return self.BaseClass.DrawHUD(self)
  end

end

function SWEP:AdjustMouseSensitivity()
return (self:GetIronsights() and 0.5) or nil
end
end

if IsMounted(“cstrike”) then
SWEP.Category = “CS:S Weapon Alternates”
SWEP.PrintName = “FAMAS”
end

if GetConVar(“M9KDefaultClip”) == nil then
print(“M9KDefaultClip is missing! You may have hit the lua limit!”)
else
if GetConVar(“M9KDefaultClip”):GetFloat() >= 0 then
SWEP.Primary.DefaultClip = SWEP.Primary.DefaultClip * GetConVar(“M9KDefaultClip”):GetFloat()
PainMulti = GetConVar(“M9KDefaultClip”):GetFloat()
else return end
end

[/lua]

Make the DefaultClip reset to 0 after it has been picked up the first time; it should prevent it from giving ammo in the future. If that doesn’t work, set it to 0 by default, and give the player ammo once; set a variable self.GaveAmmo = true; server-side, and it won’t give any more ammo on pickup.

Sorry, I’m not very good with Lua. How would one go on about doing that?

Don’t use this script I always see people using. Your best bet is to take the Mac10’s code in gamemodes/terrortow/gamemodes/entities/weapons/weapon_zm_mac10.lua and replace the models and damage values. Stuff like SWEP.Primary.RPM and SWEP.Primary.IronAccuracy don’t do anything.