Discuss Public Service Announcement Sleep() SUCKS

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,093
78,998
2,372
I have 2 threads in my AC hack and one of them had 3 sleep()'s in it. Seemingly randomly, it would be buggy and not fire when activated, it would be unresponsive and the timing was very innacurate. The time from when I activated the aimbot to when it would shoot would vary.

Now I use std::this_thread::sleep_for and all the bugs are gone! Plus it's new and shiny!
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
stl definetly offers many better alternatives to the native APIs. It's okay to use Sleep too though, I personally use Sleep(0) on some occasions; Also I suggest to read up on Sleep on MSDN, its remarks give insight on improving its accuracy.
 

GAFO666

Hacker
Meme Tier VIP
Aug 19, 2012
520
3,188
23
hmm if you guys used sleep to prevent the program from doing something within a function which shouldnt hold and got problems with that .. like in dx or whutever

my tiny class:
C++:
#pragma once
#include <Windows.h>
#include <time.h>

class TimeManager
{
public:
	TimeManager(DWORD IdleTime);
	~TimeManager();

private:
	DWORD _timeFactor;
	DWORD _idleTime;

public:
	void SetIdleHere();
	bool IsIdleOver();

	DWORD ReturnIdleTime();
	void SetIdleTime(DWORD IdleTime);
};
C++:
#include "TimeManager.h"


TimeManager::TimeManager(DWORD IdleTime)
{
	_timeFactor = IdleTime;
	_idleTime = 0;
}


TimeManager::~TimeManager()
{
}

void TimeManager::SetIdleHere()
{
	_idleTime = GetTickCount();
	_idleTime = _idleTime + _timeFactor;
}

bool TimeManager::IsIdleOver()
{
	DWORD temp = GetTickCount();
	
	if (temp >= _idleTime)
		return true;

	return false;
}

DWORD TimeManager::ReturnIdleTime()
{
	return _timeFactor;
}

void TimeManager::SetIdleTime(DWORD IdleTime)
{
	_timeFactor = IdleTime;
}
Usage:
C++:
TimeManager* time = new TimeManager(300);//time in ms,   1sec = 1000

while(1) // or e.g. endscene or dip or whatever
{
   //do sh!t
   if(time->IsIdleOver())
   {
        //do shit
        time->SetIdleHere();
   }
  //do shit
}
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods