[LUA] How would i go about doing this.

Hello im realy stuck on this piece of code.

Ive recently made a jaming system and need to make a sort of fake reload that is triggered when the players current weapon ammo (ie 357) has no reserve ammo left.
IF i dont do this when i reload with 0 ammo it dosnt play a reload and instantly unjams

Psuedocode:

1.1 get current magazine load and put it into a varable currentmagload
1.2 get the active weapon and put it into a varable activeweapon

1.3 if the players ammo(activeweapon) is 0 then do below
1.4 take away all the ammo left in the clip
1.5 play reload animation
1.6 when the animation is done set the clip back to currentmag

or do normal reload

Sounds easy to me

heres my code which aint working at all well some of its mine i do have permision to edit this.

[LUA]
function SWEP:Reload()
currentmagload = self.Weapon:Clip1()
activeweapon = Owner:GetActiveWeapon()
print(self.Weapon:Clip1()) \ just to make sure this function works

if Player:GetAmmoCount(activeweapon) == 0 then
self.Weapon:TakePrimaryAmmo(currentmagload)	
self.Weapon:DefaultReload(ACT_VM_RELOAD) 
self.Weapon.Ammo = currentmagload
		  	playercanshoot = true \\ just to allow the player to shoot
			chanceofjam = 2        \\ just to allow the player to shoot
end
	 // below is mostly the base code and not mine

if GetCurWepTotalAmmo() > 0 then
self.Weapon:DefaultReload(ACT_VM_RELOAD) 
		  	playercanshoot = true
			chanceofjam = 2
if !self.Owner:IsNPC() then
self.ResetSights = CurTime() + self.Owner:GetViewModel():SequenceDuration() end
end

if ( self.Weapon:Clip1() < self.Primary.ClipSize ) and !self.Owner:IsNPC() then
-- When the current clip < full clip and the rest of your ammo > 0, then

	self.Owner:SetFOV( 0, 0.3 )
	-- Zoom = 0

	self:SetIronsights(false)
	-- Set the ironsight to false

end

end
[/lua]

So how would i do this correctly ive tryed writing a function from gmod wiki
http://wiki.garrysmod.com/?title=Player.GetAmmoCount
but it only has a client side and im just boggled about the example

Yet again i have only began to code. Thanks