PDA

View Full Version : Ingame Menu



GTX
14-10-07, 03:19
hi

can anyone say me please, how i begin to write a menu for my CSS Hack?
I dont know how i do that.

I have the rh 1.0d basehook, with 2003 net opened, and if i start the hack with css, than i dont see the hack menu if i press DEL, INS, etc.. :/

can anyone help me please? ;)

Lawgiver
14-10-07, 03:30
This hack doesn't have an ingame menu.

GTX
14-10-07, 03:54
k thanks.

but how i can add a Menu?


greetz GTX

GTX
14-10-07, 04:28
hi

can you me please say, how i make with that in rh basehook a basic menu?
i know what you mean, but i cant know that, what i write in.

Mages
14-10-07, 05:06
but the hack wasnt made with a menu it wasnt supposed to be edited in game anyway it sucks use the p7 public or sumfin

GTX
14-10-07, 08:08
use the p7 public or sumfin

is there an p7 public release?

greetz

STR
15-10-07, 12:18
Well, get all the CVARS it uses then basically map out a Menu for it.


#include rhmenu.h

using namespace lawlrh;

rhmenu gMenu;

rhmenu::Menu* curMenu = NULL;

typedef rhmenu::Menu Menu;
typedef rhmenu::MenuEntry MenuEntry;

string szDirFile ( char* pszName );
void rhmenu::GetToken( istream& isFile, string& strToken )
{
char cCurrentChar;

while ( true )
{
isFile.get(cCurrentChar);

if( cCurrentChar == '\"' )
{
strToken.erase();

while ( true )
{
isFile.get(cCurrentChar);

if( !isFile || cCurrentChar == '\"' )
return;

strToken += cCurrentChar;
}
}
else if ( cCurrentChar == '{' )
{
strToken = "{";
return;
}
else if( cCurrentChar =='}' )
{
strToken = "}";
return;
}
if(!isFile)
{
strToken = "}";
return;
}
}
}

void rhmenu::GetComment( istream& isFile, string& strComment )
{
char cCurrentChar;

strComment.erase();
isFile.get( cCurrentChar );

while(( cCurrentChar == ' ' || cCurrentChar == '\t' ))
isFile.get( cCurrentChar );

if( cCurrentChar == '/' )
{
isFile.get(cCurrentChar);

if(cCurrentChar == '/')
{
while ( cCurrentChar != 0x0D && cCurrentChar != 0x0A && cCurrentChar != '\n')
{
isFile.get(cCurrentChar);
strComment += cCurrentChar;
}
}
}
}

void rhmenu::readMenu( istream& isFile, Menu* pMenu )
{
string strTemp;

while ( true )
{
GetToken ( isFile, strTemp );

if( strTemp[0] == '}' )
return;

MenuEntry newEntry;
// "name"
GetToken( isFile, newEntry.strName );

// "asdf;qqq" or {
GetToken( isFile, newEntry.strContent );

// "comment"
GetComment( isFile, newEntry.strInfo );


if( newEntry.strContent[0] == '{' )
{
newEntry.menu = new Menu;
newEntry.menu->strName = newEntry.strName;
newEntry.menu->pParent = pMenu;

pMenu->items.push_back(newEntry);

readMenu(isFile,newEntry.menu); // Recursive call
}
else
{
newEntry.menu = 0;
pMenu->items.push_back(newEntry);
}

if ( !isFile )
break;
}
}

void rhmenu::ReadMenu( const char* szFilename )
{
if( m_pBaseMenu )
return;

ifstream isMenu;
isMenu.open( szFilename );

if (isMenu.is_open() == false)
{
m_pBaseMenu = NULL;
return;
}

m_pBaseMenu = new Menu;
m_pBaseMenu->strName = " GD HL2 Hack ";
readMenu( isMenu, m_pBaseMenu );
m_bActive = false;
}

void rhmenu::Initialize( const char* szFilename)
{
m_bActive = false;
string strPath = szDirFile( const_cast<char*>( szFilename ));
ReadMenu(strPath.c_str());
}

void drawclock();

void rhmenu::DrawMenu( void )
{
if ( !m_bActive || m_pBaseMenu == NULL )
return;

if (gCvars.clock->GetInt() == 2)
drawclock();

if(!curMenu )
curMenu = m_pBaseMenu;

vector < rhmenu::MenuEntry > &items = curMenu->items;


int x = gCvars.menu_x->GetInt(),
y = gCvars.menu_y->GetInt(),
w = gCvars.menu_w->GetInt(),
h = gFontManager.iGetHUDHeight();


gDraw.DrawRectangle( x, y - ( h + 4 ), w, ( h + 4 ) , gColorManager.dwGetColorbyIndex( 5 ) );
gDraw.OutlineRectangle( x, y - ( h + 4 ), w, ( h + 4 ) , gColorManager.dwGetColorbyIndex( 7 ) );

gDraw.DrawString(gFontManager.GetHUDFont(),x + 12, y -( h + 2 ) ,gColorManager.dwGetColorbyIndex( 7 ),(char*)curMenu->strName.c_str());


int iSelectedItem = curMenu->iSelection;

int iUpperheight = iSelectedItem * h;

if( iUpperheight )
{
gDraw.DrawRectangle( x, y, w, iUpperheight, gColorManager.dwGetColorbyIndex( 5 ) );
y += iUpperheight;
}

// selection background
gDraw.DrawRectangle( x, y, w, h, gColorManager.dwGetColorbyIndex( 8 ) );
gDraw.OutlineRectangle( x, y, w, h, gColorManager.dwGetColorbyIndex( 6 ) );
y += h;

// lower background
int numItemsLeft =(int)(items.size() - iSelectedItem - 1);

if(numItemsLeft > 0)
gDraw.DrawRectangle( x, y, w, numItemsLeft * h + 10, gColorManager.dwGetColorbyIndex( 5 ) );

gDraw.OutlineRectangle( x, gCvars.menu_y->GetInt(),w,(int)items.size()*h + 10, gColorManager.dwGetColorbyIndex( 7 ) );

// draw text
y = gCvars.menu_y->GetInt();
x += 4;

DWORD dwTextColor = gColorManager.dwGetColorbyIndex( 9 );

for(unsigned int i = 0; i < items.size(); i++ )
{
rhmenu::MenuEntry& item = items[i];

gDraw.DrawString( gFontManager.GetHUDFont(), x, y, dwTextColor, const_cast < char* > ( item.strName.c_str() ) );
y += h;
}

if (curMenu->iSelection >= 0 && curMenu->iSelection < curMenu->items.size())
{
if( curMenu->items[curMenu->iSelection].strInfo.length() > 1 )
{
gDraw.DrawString( gFontManager.GetHUDFont(), x, y + 12, dwTextColor, const_cast < char* > ( curMenu->items[curMenu->iSelection].strInfo.c_str() ) );
return;
}
}

gDraw.DrawString( gFontManager.GetHUDFont(), x, y + 12, dwTextColor, "no info specified" );
}

void rhmenu::func_menu_up()
{
if( !curMenu || m_pBaseMenu == NULL)
return;

curMenu->iSelection--;
curMenu->boundSelection();
}


void rhmenu::func_menu_down()
{
if(!curMenu)
return;

curMenu->iSelection++;
curMenu->boundSelection();
}


void rhmenu::func_menu_select()
{
if (m_pBaseMenu == NULL)
return;

if(!curMenu)
{
curMenu = gMenu.m_pBaseMenu;
m_bActive = true;
return;
}

rhmenu::MenuEntry& entry = curMenu->items[curMenu->iSelection];

if(entry.menu)
{
curMenu = entry.menu;
curMenu->boundSelection();
}
else
{
gEngineFuncs.ClientCmd ( entry.strContent.c_str() );
}
}


void rhmenu::func_menu_back()
{
if (!curMenu || !m_bActive || !m_pBaseMenu)
return;

curMenu = curMenu->pParent;

if(!curMenu)
m_bActive = false;
else
curMenu->boundSelection();
}


void rhmenu::func_menu_activate( void )
{
if (!m_bActive)
curMenu = gMenu.m_pBaseMenu;
else
curMenu = NULL;

m_bActive = !m_bActive;
}save that as rhmenu.cpp


#ifndef _rhmenu_H_
#define _rhmenu_H_

using namespace lawlrh;

class rhmenu
{
public:
struct Menu;

struct MenuEntry
{
MenuEntry( void ) : menu( 0 ) { }

string strName;
string strContent;
string strInfo;
Menu* menu;
};

struct Menu
{
Menu():pParent(0),iSelection(0){}
void boundSelection()
{
if(iSelection < 0)
{
iSelection = (int)items.size()-1;
}
else
{
if (iSelection >= (int)items.size())
iSelection = 0;
}
}

Menu* pParent;
string strName;
int iSelection;
vector <MenuEntry> items;
};

rhmenu():m_pBaseMenu(0){ m_bActive = false; }
void DrawMenu ( void );
void Initialize ( const char* szFilename);
void ReadMenu ( const char* szFilename );
void readMenu ( istream& isFile, Menu* pMenu );
void GetComment ( istream& isFile, string& strComment );
void GetToken ( istream& isFile, string& strToken );
//--------------------------------------------------
void cvar_here_back ( void );
void cvar_here_select ( void );
void cvar_here_down ( void );
void cvar_here_up ( void );
void cvar_here_activate ( void );

private:
bool m_bActive;
struct Menu* m_pBaseMenu;
};

extern class rhmenu gMenu;

#endif
thats a hlh menu, but it wont work i was basically exampling it in your case.
so dont add it to your Basehook and compile it complaining about errors

rofl that fails hard.

GTX
15-10-07, 06:43
ok, last question:

How i can draw anything Ingame?
i would to draw a Textstring on the right side of my Display while i play on a CSS-Server.

Thx ;)

Zєяo
15-10-07, 07:20
you want to draw something? get a life dude :):):)

GTX
15-10-07, 07:31
you want to draw something? get a life dude :):):)


yes.
i want to show for the User what is turned on:




..............................................
....................................Menu...
....................................Aim "0".
..............................................
..................Weapon..................
..............................................
..10/30.......................HP/PZ......


I want to do that ingame, but how i can do it? ;)

Greetz

@Fum1n: Read please my PM ;)

GTX
16-10-07, 05:55
EDIT:

I have founded it out how to make it very easy ;)

Greetz