AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   How do I display a menu in a module? (https://forums.alliedmods.net/showthread.php?t=12201)

Geesu 04-08-2005 00:14

How do I display a menu in a module?
 
Basically ask the question asks, if I try UTIL_ShowMenu, I get an identifier not found...

Is there another way?

Also, after I display the menu, how can I catch the result?

Thanks,
Josh

PM 04-08-2005 08:07

Get the UTIL_ShowMenu from AMXX / HLSdk ;)

You have to catch the menuselect commands. If the user presses 2, you get:

menuselect 2

Or something.

Geesu 04-08-2005 16:41

so I won't know if the user like opens my menu... then say presses the button for the radio button, will I still get the same result?

Geesu 04-08-2005 17:11

OK I thought I had it working but I get an error on the following line:

Code:
void UTIL_ShowMenu( edict_t* pEdict, int slots, int time, char *menu, int mlen ) {     char *n = menu;     char c = 0;     int a;     if (!gmsgShowMenu)         return;                         // some games don't support ShowMenu (Firearms)     while ( *n ) {         a = mlen;         if ( a > 175 ) a = 175;         mlen -= a;         c = *(n+=a);         *n = 0;                                     <<<<< Crashes here         MESSAGE_BEGIN( MSG_ONE , gmsgShowMenu, NULL, pEdict );         WRITE_SHORT( slots );         WRITE_CHAR( time );         WRITE_BYTE( c ? TRUE : FALSE);         WRITE_STRING( menu );         MESSAGE_END();         *n = c;         menu = n;     } }

I invoke it with:

Code:
    char *pimp = " Yo YO YO\n\0";     UTIL_ShowMenu(pEntity, (0<<1), -1, pimp, (int)strlen(pimp));

Any suggestions?

Greenberet 05-08-2005 10:26

Quote:

Originally Posted by Geesu
Code:
    char *pimp = " Yo YO YO\n\0";

delete the '\0' from your code.
if u write it in quotes, then it has automatically an '\0'.

in your pimp array u will see this:
Code:
  char *pimp = { ' ', 'Y', 'o', ' ', 'Y',  'O', ' ', 'Y',  'O', '\n', '\0', '\0' };
You see, that u have 2 '\0'. Ok it costs only 1 byte more of RAM, but if u have to code on things like an micromaster, there you dont have much of ram^^.

so just write:
Code:
    char *pimp = " Yo YO YO\n";


All times are GMT -4. The time now is 10:42.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.