Raised This Month: $ Target: $400
 0% 

Amxx 1.8.3 New Menus Timeout (Handler hook)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 03-29-2017 , 22:50   Amxx 1.8.3 New Menus Timeout (Handler hook)
Reply With Quote #1

Hi all, i am trying to implement new menu system using a timeout menu from amxx 1.8.3.

My doubt is why callback is not called (MENU_TIMEOUT) when i use other menu (Buy menu, radio commands or simple do not open any menu)...

Also i tried only on old menus system wth (setinfo _vgui_menus 0).

Code used:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_plugin("Test Menu",AMXX_VERSION_STR,"AMXX Dev Team");
    
    
register_clcmd("amx_test_menu","fnTestMenu",ADMIN_ALL,"Test my awesome menu");
}

public 
fnTestMenu(id)
{
    new 
iMenu menu_create("Players:","fnMenuHandle");
    
    new 
iPlayers[MAX_PLAYERS],iNum,iPlayer;
    
get_players(iPlayers,iNum,"h");
    
    new 
szName[MAX_NAME_LENGTH],szNum[3];
    
    for(new 
i;iNum;i++)
    {
        
iPlayer iPlayers[i];
        
        if(
iPlayer != id// Skip-me
        
{
            
num_to_str(iPlayer,szNum,charsmax(szNum));
            
get_user_name(iPlayer,szName,charsmax(szName));
            
            
menu_additem(iMenu,szName,szNum);
        }
    }
    
    
menu_setprop(iMenu,MPROP_EXIT,MEXIT_NEVER);
    
menu_display(id,iMenu,0,10// 10 Seconds
    
    
return PLUGIN_HANDLED;
}

public 
fnMenuHandle(id,iMenu,iKey)
{
    if(
iKey != MENU_EXIT)
    {
        new 
iAccess,szData[3],szOption[MAX_NAME_LENGTH],iBack;
        
menu_item_getinfo(iMenu,iKey,iAccess,szData,charsmax(szData),szOption,charsmax(szOption),iBack);
        
        new 
iPlayer str_to_num(szData);
        
        
user_kill(iPlayer);
        
        new 
szName[2][32];
        
get_user_name(id,szName[0],charsmax(szName[]));
        
get_user_name(iPlayer,szName[1],charsmax(szName[]));
        
        
client_print(id,print_team_red,"^3%s Killed ^4%s^1...",szName[0],szName[1]);
    }
    else if(
iKey == MENU_TIMEOUT)
    {
        
client_print(id,print_team_red,"^3Players menu closed, try again...");
    }
    
    return 
PLUGIN_HANDLED;

I really know that is a better way to detect a timeout in new menus, or make some check to avoid this problem. But why i can't use MENU_TIMEOUT even if i open other menu (or not)?

Sorry if it is a n00b question, but i did not find any thing on documentation.

Thanks for help
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 03-29-2017 at 22:52.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 17:56.


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