DrawButton problem

Posts 113 of 13 · Page 1 of 1
DrawButton problem
Ok guys.
I made a func to draw a button and it have hover effe*** and click effects.
But hwen i try to change a hack variable from 0 to 1(hack =! hack)
than it dont work.

My code:
Code:
void DrawButton(int x, int y, int h, D3DCOLOR BorderColor, D3DCOLOR FillColor, char* Caption, int hack, LPDIRECT3DDEVICE9 pDevice)
{
	gets (Caption);
	if(isMouseinRegion(menux+x,menuy+y,menux+x+strlen(Caption)*6,menuy+y+h) && !GetAsyncKeyState(VK_LBUTTON))
	{
		DrawBox(menux+x, menuy+y, strlen(Caption)*6, h, TransGrey, BorderColor, pDevice);
		DrawString(menux+x+3, menuy+y+h/6, White, Directx_Font, Caption);
	}
	else if(isMouseinRegion(menux+x,menuy+y,menux+x+strlen(Caption)*6,menuy+y+h) && GetAsyncKeyState(VK_LBUTTON))
	{
		DrawBox(menux+x, menuy+y, strlen(Caption)*6, h, Yellow_a, BorderColor, pDevice);
		DrawString(menux+x+6, menuy+y+h/4, White, Directx_Font, Caption);
		hack = !hack;
	}
	else if(!isMouseinRegion(menux+x,menuy+y,menux+x+strlen(Caption)*6,menuy+y+h))
	{
		DrawBox(menux+x, menuy+y, strlen(Caption)*6, h, FillColor, BorderColor, pDevice);
		DrawString(menux+x+3, menuy+y+h/6, White, Directx_Font, Caption);
	}
}
and my call:
Code:
DrawButton(10, 10, 20, White, TransBlack, "lol", lol, pDevice);
Why my vaiable dont change?!
hack = !hack; lol?
Cuz hack is it's own variable in the method.

You can pass by reference if you want lol to actually change.
hack = !hack is for bool
and if u want to change an external value u must make it with the & operator

void DrawButton(int x, int y, int h, D3DCOLOR BorderColor, D3DCOLOR FillColor, char* Caption, int &hack, LPDIRECT3DDEVICE9 pDevice)
Quote Originally Posted by kotentopf View Post
hack = !hack is for bool
and if u want to change an external value u must make it with the & operator

void DrawButton(int x, int y, int h, D3DCOLOR BorderColor, D3DCOLOR FillColor, char* Caption, int &hack, LPDIRECT3DDEVICE9 pDevice)
hack = !hack will still work though.
Quote Originally Posted by Crash View Post
hack = !hack will still work though.
i know
but i think we both know what can happens^^
Thx kotentopf It works

PS: u can change ints like bools from 1 to 0

Kotentopf hast du skype??
1 Wont u need a pointer to really change hack.
2 why not just return hack instead of all of this..
3 that button will flicker like hell.
4 what is the point of the colors if u use something else... hmm i guess the real color only shows when u are not over it.
5 Hmm i might just release a function for button .... but i have other things to do srry bye.
Quote Originally Posted by topblast View Post
1 Wont u need a pointer to really change hack.
2 why not just return hack instead of all of this..
3 that button will flicker like hell.
4 what is the point of the colors if u use something else... hmm i guess the real color only shows when u are not over it.
5 Hmm i might just release a function for button .... but i have other things to do srry bye.
Lol button function.. You can make one with like 18 lines or less..
Quote Originally Posted by whit View Post


Lol button function.. You can make one with like 18 lines or less..
my one is 16 lines long
but i need just 11

when i add the drawfunctions of fillrgb there is much more


Code:
void cButton::Draw(LPDIRECT3DDEVICE9 pDevice)
{
	if(this->w < 40)
		this->w = 40;
	if(this->h < 15)
		this->h = 15;

	if(Hack.Readys.MouseIsOver(this->x,this->y,this->w,this->h)){
		D3D.Draw.Box(this->x,this->y,this->w,this->h,1,0xFF2B6DFF,0xFF000000,pDevice,false,false);
		if(GetAsyncKeyState(1)&1)
			this->Return = true;
	}else{
		D3D.Draw.Box(this->x,this->y,this->w,this->h,1,0xFF2B6DBF,0xFF000000,pDevice,false,false);
	}
	D3D.Draw.String(this->x + 2,this->y,0xFF3DFFFF,D3D.Settings.pFont,Hack.Misc.Encrypt(this->Text));
}
Quote Originally Posted by kotentopf View Post
my one is 16 lines long
but i need just 11

when i add the drawfunctions of fillrgb there is much more
Topblast just makes it sound so hard
Quote Originally Posted by whit View Post


Topblast just makes it sound so hard
Code:
if(CodeStuff > U_NEED)
{
	Brain->ConfuseLevel++;
	Code->MistakesAndErrors++;
	PC->RAM++;

	return OH_SHIT(ComplettlyCode);
}
You can do the same with less line of code for example this is mine
Code:
void DrawCheckBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor,char* Text,bool &hack ,IDirect3DDevice9* pDevice )
{
	FillRGB( x, y, w, h,		BoxColor, pDevice );
	DrawBorder( x, y, w, h, 2,	BorderColor, pDevice );
	DrawString(x+20,y,White,Directx_Font,Text);
	if(isMouseinRegion(x,y,x+15,y+15)){
if(GetAsyncKeyState(VK_LBUTTON)&1){
	FillRGB( x, y, w, h,		White, pDevice );
hack =! hack; 
}}

}
Result
DrawCheckBox(60,60,15,15,Black,Red, "NX Chams",nx,pDevice);
Posts 113 of 13 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?