myEntity = 0

	function Deploy()
		_GModText_Start("Default")
		 _GModText_SetPos(-1, 0.6)
		 _GModText_SetColor(255, 0, 0, 255)
		 _GModText_SetTime(9999, 0.4, 0.4)
		 _GModText_SetText("[Move/Rotate/Remove Tool]\nUse your directional keys to move. Hold USE to rotate.\nReload to remove. Right mouse to deselect.")
		_GModText_Send(userid, 1666)
	end

	function onDrop(playerid)
		_GModText_Hide(playerid, 1666, 0.25)
		_GModText_Hide(playerid, 1667, 0.25)
		_GModText_Hide(playerid, 1668, 0.25)
	end

	function onDrop()
		_GModText_Hide(Owner, 1666, 0.25)
		_GModText_Hide(Owner, 1667, 0.25)
		_GModText_Hide(Owner, 1668, 0.25)
	end
	
	function Holster()
		onDrop()
	end

	function onInit()
		_SWEPSetSound( MyIndex, "single_shot", "Weapon_AR2.Reload_Push" )
	end

	function IsVisible()
		_TraceLine(_PlayerGetShootPos(Owner), vecNormalize(vecSub(_EntGetPos(myEntity), _PlayerGetShootPos(Owner))), 9999, Owner)
		local a = _TraceHitNonWorld() and _TraceGetEnt() == myEntity
		_TraceLine(_PlayerGetShootPos(Owner), _PlayerGetShootAng(Owner), 9999, Owner)
		local b = _TraceHitNonWorld() and _TraceGetEnt() == myEntity
		return a or b
	end

	function onThink()
		if _EntGetType(myEntity) ~= "prop_dynamic" then
			myEntity = 0
		else
			if not IsVisible() then
				myEntity = 0
				_PrintMessage(Owner, 4, "Prop is out of view.")
				return
			end
		end

		if myEntity > 0 then
			if _PlayerIsKeyDown(Owner, IN_USE) then
				if _PlayerIsKeyDown(Owner, IN_FORWARD) then
					_EntSetAng(myEntity, vecAdd(_EntGetAng(myEntity), vector3(0.05, 0, 0)))
				elseif _PlayerIsKeyDown(Owner, IN_BACK) then
					_EntSetAng(myEntity, vecAdd(_EntGetAng(myEntity), vector3(-0.05, 0, 0)))
				elseif _PlayerIsKeyDown(Owner, IN_MOVERIGHT) then
					_EntSetAng(myEntity, vecAdd(_EntGetAng(myEntity), vector3(0, 0, 0.05)))
				elseif _PlayerIsKeyDown(Owner, IN_MOVELEFT) then
					_EntSetAng(myEntity, vecAdd(_EntGetAng(myEntity), vector3(0, 0, -0.05)))
				end
			else
				if _PlayerIsKeyDown(Owner, IN_JUMP) then
					_EntSetPos(myEntity, vecAdd(_EntGetPos(myEntity), vector3(0,0,5)))
				elseif _PlayerIsKeyDown(Owner, IN_DUCK) then
					_EntSetPos(myEntity, vecAdd(_EntGetPos(myEntity), vector3(0,0,-5)))
				end
				if _PlayerIsKeyDown(Owner, IN_FORWARD) then
					_EntSetPos(myEntity, vecAdd(_EntGetPos(myEntity), vecMul(vector3(5,5,0), _PlayerGetShootAng(Owner))))
				elseif _PlayerIsKeyDown(Owner, IN_BACK) then
					_EntSetPos(myEntity, vecAdd(_EntGetPos(myEntity), vecMul(vector3(-5,-5,0), _PlayerGetShootAng(Owner))))
				elseif _PlayerIsKeyDown(Owner, IN_MOVERIGHT) then
					_EntSetPos(myEntity, vecAdd(_EntGetPos(myEntity), vecMul(vector3(5,5,0), _EntGetRightVector(Owner))))
				elseif _PlayerIsKeyDown(Owner, IN_MOVELEFT) then
					_EntSetPos(myEntity, vecAdd(_EntGetPos(myEntity), vecMul(vector3(-5,-5,0), _EntGetRightVector(Owner))))
				end
			end
			_RunString("CheckIllegalProp("..myEntity..")")
		end
	end

	function onPrimaryAttack()
		_TraceLine(_PlayerGetShootPos(Owner), _PlayerGetShootAng(Owner), 8000, Owner)
		if _TraceHit() then
			if _TraceHitNonWorld() and _TraceGetEnt() > _MaxPlayers() then
				if _EntGetType(_TraceGetEnt()) == "prop_dynamic" then
					_RunString("selectProp("..Owner..", ".._TraceGetEnt()..")")
				end
			end
		end
	end
	
	function onSecondaryAttack()
		if myEntity > 0 then
			myEntity = 0
			_PrintMessage(Owner, 4, "Prop selection cleared")
			_PlayerLockInPlace(Owner, false)
			_GModText_Hide(Owner, 1668, 0.25)
		end
	end

	function onReload()
		if myEntity > 0 then
			_RunString("removeProp("..Owner..", "..myEntity..")")
			myEntity = 0
			_PrintMessage(Owner, 4, "Prop deleted.")
			_PlayerLockInPlace(Owner, false)
			_GModText_Hide(Owner, 1668, 0.25)
			return false
		end
	end

	function getWeaponSwapHands()
		return false	
	end
	
	function getWeaponFOV()
		return 60	
	end
	
	function getWeaponSlot()
		return 1	
	end
	
	function getWeaponSlotPos()
		return 6	
	end
	
	function getFiresUnderwater()
		return true
	end
	
	function getReloadsSingly()
		return false
	end
	
	function getDamage()
		return 5
	end
	
	function getPrimaryShotDelay()
		return 0.75
	end
	
	function getSecondaryShotDelay()
		return 0.75
	end
	
	function getPrimaryIsAutomatic()
		return false
	end
	
	function getSecondaryIsAutomatic()
		return false
	end
	
	function getBulletSpread()
		return vector3( 0.00, 0.00, 0.00 )
	end
	
	function getViewKick()
		return vector3( 0.0, 0.0, 0.0)
	end
	
	function getViewKickRandom()
		return vector3( 0.0, 0.0, 0.0 )
	end

	function getViewModel( )
		return "models/weapons/v_crossbow.mdl"
	end
	
	function getWorldModel( )
		return "models/weapons/w_crossbow.mdl"
	end
	
	function getClassName()
		return "weapon_manipulator"
	end

	function getPrimaryAmmoType()
		return
	end
		
	function getSecondaryAmmoType()
		return
	end
	
	function getMaxClipPrimary()
		return 1
	end
	
	function getMaxClipSecondary()
		return -1
	end

	function getDefClipPrimary()
		return 1
	end
	
	function getDefClipSecondary()
		return 1
	end

	function getAnimPrefix()
		return "pistol"
	end

	function getPrintName()
		return "Prop Manipulator"
	end
	
	function getPrimaryScriptOverride()
		return 1
	end

	function getSecondaryScriptOverride()
		return 3
	end

	function getBulletSpreadSecondary()
		return vector3( 0.0, 0.0, 0.0 )
	end
	
	function getViewKickSecondary()
		return vector3( 0.0, 0.0, 0.0)
	end
	
	function getViewKickRandomSecondary()
		return vector3( 0.0, 0.0, 0.0 )
	end
