if ( SERVER ) then
	AddCSLuaFile( "shared.lua" )
	SWEP.Weight				= 5
	SWEP.AutoSwitchTo		= false
	SWEP.AutoSwitchFrom		= false
	SWEP.HoldType			= "smg"
end

SWEP.Author = "Silverlan"
SWEP.Contact = "Silverlan@gmx.de"
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.Base = "base_swep_tf"
SWEP.Category		= "Team Fortress 2"

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.ViewModel = "models/weapons/v_models/v_pda_engineer.mdl"
SWEP.WorldModel = "models/weapons/w_models/w_toolbox.mdl"

SWEP.Primary.Delay			= 0.8

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.ShootInWater		= true
SWEP.Primary.Ammo			= "none"

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

/*---------------------------------------------------------
   Name: SWEP:Deploy( )
   Desc: Whip it out
---------------------------------------------------------*/
function SWEP:Deploy( )
	if !self then return end
	ironsight_ply = nil

	self.reloading = false
	self.r_emit = false
	self.add_prim = nil
	
	self:Draw()
	return true
end

function SWEP:Draw()
	self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
	timer.Create( "VM_Idle_anim_timer_2" .. self:EntIndex(), 1.2, 1, function() if self.Owner and (self.Owner:IsNPC() or ( self.Owner:IsPlayer() and self.Owner:GetActiveWeapon( ) == self )) then self:SendWeaponAnim( ACT_VM_IDLE ) end end )
	return true
end

function SWEP:DestroyItem( itemint )
	if itemint == 1 and self.Owner.sentry and ValidEntity(self.Owner.sentry) then
		self.Owner.sentry:Explode()
	elseif itemint == 2 and self.Owner.dispenser and ValidEntity(self.Owner.dispenser) then
		self.Owner.dispenser:Explode()
	elseif itemint == 3 and self.Owner.tp_entrance and ValidEntity(self.Owner.tp_entrance) then
		self.Owner.tp_entrance:Explode()
	elseif itemint == 4 and self.Owner.tp_exit and ValidEntity(self.Owner.tp_exit) then
		self.Owner.tp_exit:Explode()
	end
	
	self.targetitem = nil
end

function KeyPressed(ply,cmd,args)
	local str = string.Explode(" ", args[1] )
	local weapon = ents.GetByIndex( str[1] )
	local key = str[2]
	if !weapon or !ValidEntity(weapon) then return end
	weapon.targetitem = tonumber(key) -1
end
concommand.Add("tf_eng_weapon_pda_plypressedkey",KeyPressed)


function SWEP:Think()
	if CLIENT then return end
	if self.targetitem then
		self:DestroyItem(self.targetitem)
		return
	end
	
	if self.idledelay and CurTime() > self.idledelay then
		self.idledelay = nil
		self:SendWeaponAnim( ACT_VM_IDLE )
	end
end

/*---------------------------------------------------------
	PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
end

SWEP.NextSecondaryAttack = 0
/*---------------------------------------------------------
	SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack()
end
