Raised This Month: $ Target: $400
 0% 

Trying to create menus and intercept the results


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 04-27-2005 , 16:12   Trying to create menus and intercept the results
Reply With Quote #1

ok basically I'm trying to intercept menus using an amxx module.

I have not been able to successfully send a ShowMenu message using the source I have found in amxmodx's source (UTIL_ShowMenu).

Can anyone shed some light on this? I always get a seg fault when I try to copy and paste it and use it.

Also, after I have done this, how can I intercept the result?

And lastly, do I not even need to do this work? Is there a way my amxx module can call the existing menu functions?

My other post here: (no1 responded )

http://forums.alliedmods.net/showthread.php?t=12201
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 04-29-2005 , 18:05  
Reply With Quote #2

SOMEONE ANYONE!!!!!
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
BAILOPAN
Join Date: Jan 2004
Old 04-30-2005 , 00:00  
Reply With Quote #3

That function is really ugly and the code is typical OLOcode. I would not use it unless you understand every line.

If it's segfaulting, run it through a debugger.

I don't feel like trying to decode that mess :p
__________________
egg
BAILOPAN is offline
Anpheus
Senior Member
Join Date: Aug 2004
Old 04-30-2005 , 00:20  
Reply With Quote #4

Try changing *n = 0; to *n = ""; or something. That is a char type.
Anpheus is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-30-2005 , 04:41  
Reply With Quote #5

That function assumes that the string you pass as menu is modifyiable. This is always true in AMX Mod X, because we always pass get_amxstring's static buffer. If you pass a constant string ( like "LOL" ), it is likely to crash because the function will try to modify the (most likely read-only) part of memory where LOL is stored.

Code:
void UTIL_ShowMenu( edict_t* pEdict, int slots, int time, const char *menu)
{
    const int CHUNKSIZE = 175;
    static char tempbuffer[CHUNKSIZE + 1];

    if (!gmsgShowMenu)
        return;                            // some games don't support ShowMenu (Firearms)

    int curlen = 0;
    const char *n = menu;
    while (*n)
    {
        if (++curlen == CHUNKSIZE)
        {
            strncpy(tempbuffer, menu, CHUNKSIZE);
            tempbuffer[CHUNKSIZE] = 0;
            curlen = 0;
            menu = n + 1;
            MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pEdict);
            WRITE_SHORT(slots);
            WRITE_CHAR(time);
            WRITE_BYTE(*menu ? true : false);
            WRITE_STRING(tempbuffer);
            MESSAGE_END();
        }
        ++n;
    }
    if (curlen)
    {
        MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pEdict);
        WRITE_SHORT(slots);
        WRITE_CHAR(time);
        WRITE_BYTE(FALSE);
        WRITE_STRING(menu);
        MESSAGE_END();
    }
}
That might work, I haven't tested it though.
__________________
hello, i am pm
PM is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 04-30-2005 , 23:22  
Reply With Quote #6

worked like a charm!!!

thanks!
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:23.


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