Raised This Month: $51 Target: $400
 12% 

check if user has any menu opened


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
red_bull2oo6
Senior Member
Join Date: Mar 2012
Location: Braila, Romania
Old 10-14-2013 , 17:59   check if user has any menu opened
Reply With Quote #1

it seems that i need your help again.
i have recently found a stock that allows me to show a hud message via menu.

but there is a problem:
if the user already has opened another menu( like radio for example ) when my 'hud menu' is displayed,
it will dissapear.

how can i check if a user has any other menu opened so i can skip that player ?

here is the code:

PHP Code:

/* Plugin generated by AMXX-Studio */

    #include < amxmodx >
    
    #pragma semicolon 1
    
    
new const
        
PLUGIN_NAME[ ]         = "New Plugin",
        
PLUGIN_VERSION[ ]     = "1.0";
    
    new const 
MESSAGES11 ][ ]        = 
    {
        
"\rFun Jump-ul\d este interzis! ( \y CT\d  )",
        
"\rWait-ul\d,\r Camp-ul\d sunt intezise! ( \y CT\d  )",
        
"\rRun-ul\d,\r Hide-ul\d,\r Airflash-ul\d sunt interzise! ( \y T\d  )",
        
"\rBlock-ul\d,\r Team Block-ul\d sunt interzise!",
        
"\rUnderstab-ul\d, \rUnder Block-ul\d este interzis!",
        
"\rBoost-ul \deste interzis!",
        
"\rRetry-ul \deste interzis!",
        
"\dFara scripturi sau cvar-uri\r ilegale\d!",
        
"\dFara wait-uri sau hack-uri de orice forma!",
        
"\rFara injuraturi si limbaj vulgar!",
        
"\rRespectati\d adminii si jucatorii serverului!"
    
};
            
        
                
public 
plugin_init( )
{
    
    
register_pluginPLUGIN_NAMEPLUGIN_VERSION"" );
    
    
    
set_task10.0"task_DisplayMessage"1337__"b");
    
// Add your code here...
}

public 
task_DisplayMessage( )
{
    static 
iPlayers32 ];
    static 
iPlayersNum;
        
    
get_playersiPlayersiPlayersNum"ch" );
    if( !
iPlayersNum )
        return;
        
    static 
idi;
    for( 
0iPlayersNumi++ )
    {
        
id iPlayers];
        
CreateMenuHudidMESSAGESrandom11 ) ], );
        
    }
    
    
    
}

CreateMenuHudidszMsg[ ], iTime 5)
{
    static 
bool:bRegistered;
    
    if( !
bRegistered )
    {
        
register_menucmdregister_menuid"MenuHud" ), (1<<9), "MenuHud" );
        
bRegistered true;
    }
    
    new 
szMessage512 ], iLen;
    static const 
NEWLINE[ ] = "^n                                   ";
    static const 
NEWLINES[ ] = "^n^n^n^n^n^n^n^n^n";
    
    
iLen += formatexszMessageiLen ], sizeofszMessage ) - iLen -1"%s%s",NEWLINESNEWLINE );
    
iLen += formatexszMessageiLen ], sizeofszMessage ) - iLen -1"%s"szMsg );
    
    
replace_allszMessagesizeofszMessage ) -1"\n"NEWLINE );
    
    
    
show_menuid, (1<<9), szMessageiTime"MenuHud" );
}

// Just to let menu show
public MenuHudidkey )
{
    return 
PLUGIN_CONTINUE;

edit:
ok so it happened that i found out about:
PHP Code:
/**
 * Returns information about a menu (if any) the client is currently viewing.
 *
 * If newmenu is valid, then the menu will refer to the menuid associated with 
 * the title.  If newmenu is not valid, and the menu is valid, then the player 
 * is viewing a menu displayed with show_menu().
 *
 * Both may be invalid if the player is not viewing a menu.
 *
 * @param id            Client index.
 * @param menu            Variable to store old menu id.  If none, then <1 will be 
 *                        stored.
 * @param newmenu        Variable to store new menu id.  If none, then -1 will be 
 *                        stored.
 * @param menupage        Variable to store current page of the new menu, if any.
 * @return                1 if the player is viewing a menu, 0 otherwise.
 * @error                Invalid client.
 */
native player_menu_info(id, &menu, &newmenu, &menupage=0); 
but i don't understand how to use it.

can you help me ?
thanks in advance!
__________________

My PC Themes . .

Last edited by red_bull2oo6; 10-15-2013 at 13:56. Reason: added something
red_bull2oo6 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 10-14-2013 , 18:58   Re: check if user has any menu opened
Reply With Quote #2

Try to search a bit. Posted yesterday:
Quote:
Originally Posted by ConnorMcLeod View Post
Using this native :
Code:
/**
 * Returns information about a menu (if any) the client is currently viewing.
 *
 * If newmenu is valid, then the menu will refer to the menuid associated with 
 * the title.  If newmenu is not valid, and the menu is valid, then the player 
 * is viewing a menu displayed with show_menu().
 *
 * Both may be invalid if the player is not viewing a menu.
 *
 * @param id			Client index.
 * @param menu			Variable to store old menu id.  If none, then <1 will be 
 *						stored.
 * @param newmenu		Variable to store new menu id.  If none, then -1 will be 
 *						stored.
 * @param menupage		Variable to store current page of the new menu, if any.
 * @return				1 if the player is viewing a menu, 0 otherwise.
 * @error				Invalid client.
 */
native player_menu_info(id, &menu, &newmenu, &menupage=0);
PHP Code:
    new oldMenuIdnewMenuId;
    
player_menu_info(idoldMenuIdnewMenuId)
    if( 
newMenuId > -&& newMenuId == YOUR_MENU )
    {
        
menu_cancel(id)
    } 
Although of course you would need to make a few small edits to suite your needs.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 10-14-2013 at 19:00.
hornet is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-15-2013 , 02:53   Re: check if user has any menu opened
Reply With Quote #3

Compare oldMenu variable to value returned by register_menuid.
So, better to send register_menuid in plugin_init.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-15-2013 at 02:54.
ConnorMcLeod is offline
red_bull2oo6
Senior Member
Join Date: Mar 2012
Location: Braila, Romania
Old 10-15-2013 , 13:55   Re: check if user has any menu opened
Reply With Quote #4

i searched.. but i think i have not entered the right keyword..
although, thanks for your help .
__________________

My PC Themes . .
red_bull2oo6 is offline
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 09:22.


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