Mad Cows Reloading Problems (Unanswered Before)

For a long time I’ve been trying to make a few sweps and yet I’m still encountering problems.
-Shotguns don’t reload by shell correctly.
-Pressing the Reload button when the Clip is full causes it to make the reloading sounds repeatedly.

Yet nobody has answered to these problems. Here’s the script for one of the shotguns:


// Variables that are used on both client and server

SWEP.Base 				= "weapon_mad_base_shotgun"

SWEP.ViewModelFlip		= true
SWEP.Category			= "Synester"
SWEP.ViewModel			= "models/weapons/v_shot_misuper90.mdl"
SWEP.WorldModel			= "models/weapons/w_shot_misuper90.mdl"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= false

SWEP.Primary.Sound 		= Sound("weapons/mi/m3-1.wav")
SWEP.Primary.Recoil		= 4
SWEP.Primary.Damage		= 14
SWEP.Primary.NumShots		= 12
SWEP.Primary.Cone			= 0.055
SWEP.Primary.Delay 		= 0.90

SWEP.Primary.ClipSize		= 9					// Size of a clip
SWEP.Primary.DefaultClip	= 8					// Default number of bullets in a clip
SWEP.Primary.Automatic		= false				// Automatic/Semi Auto
SWEP.Primary.Ammo			= "Buckshot"

SWEP.Secondary.ClipSize		= -1					// Size of a clip
SWEP.Secondary.DefaultClip	= -1					// Default number of bullets in a clip
SWEP.Secondary.Automatic	= false				// Automatic/Semi Auto
SWEP.Secondary.Ammo		= "none"

SWEP.ShellDelay			= 0.53

SWEP.IronSightsPos 		= Vector (2.5529, -9.2012, 2.0868)
SWEP.IronSightsAng 		= Vector (0.5059, 0.5525, -5.5519)
SWEP.RunArmOffset 		= Vector (-2.6657, 0, 3.5)
SWEP.RunArmAngle 			= Vector (-20.0824, -20.5693, 0)

SWEP.ShotgunReloading		= false
SWEP.ShotgunFinish		= 0.5
SWEP.ShotgunBeginReload		= 0.3

/*---------------------------------------------------------
   Name: SWEP:Precache()
   Desc: Use this function to precache stuff.
---------------------------------------------------------*/
function SWEP:Precache()

    	util.PrecacheSound("weapons/mi/m3_insertshell.wav")
end

function SWEP:Reload()

	self:SetIronsights(false,self.Owner)
	self.Weapon:DefaultReload(ACT_VM_RELOAD);
	
end


And here’s the code to one of the regular guns:


// Variables that are used on both client and server

SWEP.Base 				= "weapon_mad_base_sniper"

SWEP.ViewModelFlip		= false
SWEP.Category			= "Synester"
SWEP.ViewModel			= "models/weapons/v_rif_famis.mdl"
SWEP.WorldModel			= "models/weapons/w_rif_famis.mdl"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= false

SWEP.Primary.Sound 		= Sound("weapons/famis/famas-1.wav")
SWEP.Primary.Recoil		= 1
SWEP.Primary.Damage		= 11
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0.015
SWEP.Primary.Delay 		= 0.095

SWEP.Primary.ClipSize		= 31					// Size of a clip
SWEP.Primary.DefaultClip	= 30					// Default number of bullets in a clip
SWEP.Primary.Automatic		= true				// Automatic/Semi Auto
SWEP.Primary.Ammo			= "StriderMinigun"

SWEP.Secondary.ClipSize		= -1					// Size of a clip
SWEP.Secondary.DefaultClip	= -1					// Default number of bullets in a clip
SWEP.Secondary.Automatic	= false				// Automatic/Semi Auto
SWEP.Secondary.Ammo		= "none"

SWEP.ShellEffect			= "effect_mad_shell_rifle"	// "effect_mad_shell_pistol" or "effect_mad_shell_rifle" or "effect_mad_shell_shotgun"
SWEP.ShellDelay			= 0

SWEP.IronSightsPos = Vector (-2.8957, -5.3022, 0.7235)
SWEP.IronSightsAng = Vector (2.2042, 0.4363, 0)
SWEP.RunArmOffset = Vector (6.5075, -8.5025, 3.2846)
SWEP.RunArmAngle = Vector (-31.2941, 61.6982, -5.4357)

SWEP.Type				= 3 					// 1 = Automatic/Semi-Automatic mode, 2 = Suppressor mode, 3 = Burst fire mode
SWEP.Mode				= true

SWEP.data 				= {}
SWEP.data.NormalMsg		= "Switched to automatic."
SWEP.data.ModeMsg			= "Switched to burst-fire."
SWEP.data.Delay			= 0.5 				// You need to wait 0.5 second after you change the fire mode
SWEP.data.Cone			= 1
SWEP.data.Damage			= 1
SWEP.data.Recoil			= 1
SWEP.data.Automatic		= true

SWEP.Pistol				= false
SWEP.Rifle				= false
SWEP.Shotgun			= false
SWEP.Sniper				= true

SWEP.IronSightZoom 		= 1.5
SWEP.ScopeZooms			= {10}
SWEP.ScopeScale 			= 0.4

/*---------------------------------------------------------
   Name: SWEP:Precache()
   Desc: Use this function to precache stuff.
---------------------------------------------------------*/
function SWEP:Precache()

    	util.PrecacheSound("weapons/sg550/sg550-1.wav")
end

function SWEP:Reload()
	self:SetIronsights(false,self.Owner)
	self.Weapon:DefaultReload(ACT_VM_RELOAD);
        if (SERVER) then
	self.Owner:SetFOV( 0, 0.15 )
	self.Owner:DrawViewModel(true)
	end
	self.Weapon:DefaultReload( ACT_VM_RELOAD );
		timer.Simple(0.4, function()
	self.Weapon:EmitSound("weapons/famf1/famas_clipout.wav" )
	end)
	timer.Simple(1.4, function()
	self.Weapon:EmitSound("weapons/famf1/famas_clipin.wav" )
	end)
	timer.Simple(2.1, function()
	self.Weapon:EmitSound("weapons/famf1/famas_forearm.wav" )
	end)
end

Does anybody know of any fixes to these issues?

As far as reloading sounds, make sure in your reload function you do a check to see if the user has a full clip and the user has > 0 ammunition in reserve before attempting a reload. This code is directly from **[SWEP.Reload

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=SWEP.Reload)**:
[lua]
function SWEP:Reload()

//if ( CLIENT ) then return end

self:SetIronsights( false )

// Already reloading
if ( self:GetNetworkedBool( "reloading", true ) ) then return end

// Start reloading if we can 

– This is the part that you are looking for, huntingrifle
if ( self:Clip1() < self.Primary.ClipSize && self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then

	self:SetNetworkedBool( "reloading", true )
	self:SetVar( "reloadtimer", CurTime() + 0.3 )
	self:SendWeaponAnim( ACT_VM_RELOAD )

end

end
[/lua]

Also note that this code is from a pump shotgun Swep, so it can probably help you troubleshoot reloading in the “shell” style, as well.