AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Amxx 1.8.3 New Menus Timeout (Handler hook) (https://forums.alliedmods.net/showthread.php?t=295582)

^SmileY 03-29-2017 22:50

Amxx 1.8.3 New Menus Timeout (Handler hook)
 
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


All times are GMT -4. The time now is 17:56.

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