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

Hexui Undetected CSGO Cheats PUBG Accounts

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,183
19,938
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;

	}
 
Community Mods