Solved C++ The variable does not change within the function.

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

PlayTheRace

Newbie
Dec 1, 2013
1
102
0
hi guys.
I have a problem in a function.
I want a variable to be changed within the function.
But when when the bool variable is changed inside the function, to release the hotkey it returns to its previous state.
example:
Variavel = True;
If rotkey = pressionada {
Variavel = false;

But when you release the hotkey, it returns true.

Code usage.

C++:
void HBase::DrawItem(int ItemX, int distancia, bool ativar){
	if (GetAsyncKeyState(VK_NUMPAD6)){
		ativar = true;

	}
can someone help me?
 
Last edited:

Nether

The Angel Of Verdun
Meme Tier VIP
Dank Tier Donator
Dec 11, 2013
293
3,738
16
If you still havent solved your problem maybe you could try this:

C++:
ativar = !ativar
Its basically saying:

if ativar is true set to false / if ativar is false set to true

PS: I may be wrong as Ive only been learning C++ for a short time.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
else aktivar = false?
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
to release the hotkey it returns to its previous state.
example:
Variavel = True;
If rotkey = pressionada {
Variavel = false;

But when you release the hotkey, it returns true.
I think what you need is a while loop tho,
C++:
while(!getasynckeystate(CK_KEY)) ativar = false;
but i guess you have already solved it.
 

kokole

k
Dank Tier Donator
Nobleman
Aug 1, 2012
70
628
0
I think what you need is a while loop tho,
C++:
while(!getasynckeystate(CK_KEY)) ativar = false;
but i guess you have already solved it.
Isn't this better?
C++:
ativar = false;
while(!getasynckeystate(CK_KEY))
	Sleep(10);
That way you wont set ativar to false each time it loops, and the sleep reduces CPU usage.
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
Isn't this better?
C++:
ativar = false;
while(!getasynckeystate(CK_KEY))
	Sleep(10);
That way you wont set ativar to false each time it loops, and the sleep reduces CPU usage.
you are right, the loop i showed is not good :)
Anyway since he is inside a render function he can just use an if statement.
 
Last edited:

Syperus

RTFM
Meme Tier VIP
Dank Tier Donator
Oct 29, 2012
432
2,638
7
Or
C++:
if (GetAsyncKeyState(VK_NUMPAD6) & 1){
		ativar = true;

	}
 
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