--------------------[ SPRINTING FUNCTIONS ]-------------------------------------------


function MonitorStamina()
	while Run_Key_Pressed do
		if (not Aimed) and (not Aiming) then 
			break
		end
		RS:wait()
	end
	while Run_Key_Pressed and (not Aiming) and (not Aimed) and (not Knifing) and (not ThrowingGrenade) do
		local Forward = (Keys["w"] or Keys[string.char(17)])
		local Backward = (Keys["s"] or Keys[string.char(18)])
		if (Forward and (not Backward))
		and Walking and (Stamina > 0) then
			if Stance == 1 or Stance == 2 then Stand() end
			local NewStamina = Stamina - 1
			Stamina = (NewStamina < 0 and 0 or NewStamina)
			Running = true
		elseif (not (Forward and (not Backward)))
		or (not Walking) or (Stamina == 0) then
			break
		end
		RS:wait()
	end
	Running = false
	RechargeStamina()
end

function RechargeStamina()
	ChargingStamina = true
	while ((not Run_Key_Pressed) or (Stamina < MaxStamina)) and (not Running) do
		if Stamina < MaxStamina then
			local NewStamina = Stamina + (S.SprintTime / S.StaminaCoolTime)
			Stamina = (NewStamina > MaxStamina and MaxStamina or NewStamina)
		elseif Stamina >= MaxStamina then
			break
		end
		RS:wait()
	end
	ChargingStamina = false
end
