if (SERVER) then AddCSLuaFile("shared.lua") end
if(CLIENT) then
	SWEP.PrintName			= "M4A4 (CSGO)"			
	SWEP.Author				= "Counter-Strike: Global Offensive"
	SWEP.Slot				= 3
	SWEP.SlotPos			= 5
	SWEP.IconLetter			= "w"
	
	killicon.AddFont( "weapon_ar_m4a4", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
	
	--util.PrecacheSound("weapons/pistol/pistol_reload1.wav")
	--util.PrecacheSound("csgo/m4a1/m4a1_unsil-1.wav")
end

SWEP.HoldType			= "ar2"
SWEP.Base				= "weapon_classiq_base"
SWEP.Category			= "Counter-Strike: Global Offensive"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true

SWEP.UseHands 			= true
SWEP.ViewModelFlip		= false
SWEP.ViewModelFOV		= 55
SWEP.ViewModel			= "models/weapons/c_csgo_m4a1.mdl"
SWEP.WorldModel			= "models/weapons/csgo_world/w_rif_m4a1.mdl"

SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Primary.Sound			= Sound("M4A4_CSGO.Single")
SWEP.Primary.Reload 		= Sound("")
SWEP.Primary.Recoil 		= 0.2
SWEP.Primary.Damage 		= 32
SWEP.Primary.NumShots 		= 0
SWEP.Primary.Cone 		= 0.01
SWEP.Primary.ClipSize 		= 30
SWEP.Primary.Delay 		= 0.085
SWEP.Primary.DefaultClip 	= 120
SWEP.Primary.Automatic 		= true
SWEP.Primary.Ammo 		= "smg1"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"


SWEP.IronSightsPos = Vector(-4.721, -4.73, 0.72)
SWEP.IronSightsAng = Vector(-0.05, 0.046, 0)


function SWEP:DrawWorldModel()
	if not IsValid(self.Owner) then self:DrawModel() return end

	local hand, offset, rotate
	hand = self.Owner:GetAttachment(self.Owner:LookupAttachment("anim_attachment_rh"))
	offset = hand.Ang:Right() * 0.5 + hand.Ang:Forward() * 1 + hand.Ang:Up() * -1

	hand.Ang:RotateAroundAxis(hand.Ang:Right(), 0)
	hand.Ang:RotateAroundAxis(hand.Ang:Forward(), 10)
	hand.Ang:RotateAroundAxis(hand.Ang:Up(), 0)

	self:SetRenderOrigin(hand.Pos + offset)
	self:SetRenderAngles(hand.Ang)

	self:DrawModel();if (CLIENT) then self:SetModelScale(1,1,1) end
end

--
-- Sound data
--
sound.Add({
	name = 			"M4A4_CSGO.Single",
	channel = 		CHAN_USER_BASE+10,
	volume = 		1.0,
	sound = 		"csgo/m4a1/m4a1_unsil-1.wav"
})

local soundData = {
    name 		= "Weapon_Cm4a1.Clipout" ,
    channel 	= CHAN_ITEM,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "csgo/m4a1/m4a1_clipout.wav"
}

sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.Clipin" ,
    channel 	= CHAN_ITEM,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "csgo/m4a1/m4a1_clipin.wav"
}
sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.BoltForward" ,
    channel 	= CHAN_ITEM,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "csgo/m4a1/m4a1_boltforward.wav"
}

sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.BoltBack" ,
    channel 	= CHAN_ITEM,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "csgo/m4a1/m4a1_boltback.wav"
}

sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.Draw" ,
    channel 	= CHAN_ITEM,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "csgo/m4a1/m4a1_draw.wav"
}

sound.Add(soundData)