Raised This Month: $ Target: $400
 0% 

menu_display() issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
paiNflCltch
Junior Member
Join Date: Sep 2012
Old 09-29-2012 , 06:20   menu_display() issue
Reply With Quote #1

Hi. I need use menu_display() to show the last page what an user have saw, cause when he did his choice the menu will open in the same page.

I used this but it don't work.
Code:
/* Menu Page */ new mPage[33]; public cmdMenu(id) {     new menu = menu_create("Menu :", "MenuHandler");         /* Items goes here */     menu_display(id, menu, mPage[id]);     return PLUGIN_HANDLED; } public MenuHandler(id, menu, item) {     if(item == MENU_EXIT)     {         mPage[id] = 0;                 menu_destroy(menu);         return PLUGIN_HANDLED;     }         if(item == MENU_MORE)         mPage[id]++;         if(item == MENU_BACK && mPage[id] > 0)         mPage[id]--;         new iData[6], iName[64], Access, Callback;     menu_item_getinfo(menu, item, Access, iData, charsmax(iData), iName, charsmax(iName), Callback);         new Target = str_to_num(iData);         /* Choices goes here */     menu_display(id, menu, mPage[id]);     return PLUGIN_HANDLED; }

Thanks.

Last edited by paiNflCltch; 09-29-2012 at 06:20.
paiNflCltch is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-29-2012 , 07:18   Re: menu_display() issue
Reply With Quote #2

PHP Code:
public MenuHandler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
mPage[id] = 0;
        
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
iData[6], iName[64], AccessCallback;
    
menu_item_getinfo(menuitemAccessiDatacharsmax(iData), iNamecharsmax(iName), Callback);
    
    new 
Target str_to_num(iData);
    
    
/* Choices goes here */

    
new crap
    player_menu_info
(idcrapcrapmPage[id]);
    
menu_display(idmenumPage[id]);
    return 
PLUGIN_HANDLED;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
paiNflCltch
Junior Member
Join Date: Sep 2012
Old 09-29-2012 , 07:41   Re: menu_display() issue
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
public MenuHandler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
mPage[id] = 0;
        
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
iData[6], iName[64], AccessCallback;
    
menu_item_getinfo(menuitemAccessiDatacharsmax(iData), iNamecharsmax(iName), Callback);
    
    new 
Target str_to_num(iData);
    
    
/* Choices goes here */

    
new crap
    player_menu_info
(idcrapcrapmPage[id]);
    
menu_display(idmenumPage[id]);
    return 
PLUGIN_HANDLED;

Thanks!
One more question. I've done a Players menu, but the first option of the menu is not a Player, when I test the plugin the choice 1 works good, but the others choice ins't working.
I think is because I use.

Code:
switch(Target) {     case 1 : /* Choice 1 */     default : /* Choice 2..7 */ }

What I must use there?

Last edited by paiNflCltch; 09-29-2012 at 07:41.
paiNflCltch is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-29-2012 , 07:44   Re: menu_display() issue
Reply With Quote #4

PHP Code:
#define PLMENU_OBEY_IMMUNITY (1<<0)
#define PLMENU_ALLOW_SELF    (1<<1)
#define PLMENU_ONLY_ALIVE    (1<<2)
#define PLMENU_NO_BOTS        (1<<3)

MakePlayerMenu(id, const szMenuTitle[], const szMenuHandler[], iFlags PLMENU_OBEY_IMMUNITY)
{
    new 
iMenu menu_create(szMenuTitleszMenuHandler)
    new 
bool:bIsSuperAdmin
    
if( iFlags PLMENU_OBEY_IMMUNITY )
    {
        
bIsSuperAdmin = !!(get_user_flags(id) & ADMIN_RCON)
    }

    new 
iPlayers[32], iNumiPlayerszPlayerName[32], szUserId[32]
    new 
szFlags[4] = "h"
    
if( iFlags PLMENU_ONLY_ALIVE )
    {
        
szFlags[++iNum] = 'a'
    
}
    if( 
flags PLMENU_NO_BOTS )
    {
        
szFlags[++iNum] = 'c'
    
}

    
get_players(iPlayersiNumszFlags)

    for(--
iNumiNum>=0iNum--)
    {
        
iPlayer iPlayers[iNum]
        
get_user_name(iPlayerszPlayerNamecharsmax(szPlayerName))

        if(    
iFlags PLMENU_OBEY_IMMUNITY && !bIsSuperAdmin
        
&&    ( (get_user_flags(iPlayer) & ADMIN_IMMUNITY) && 
            ((
iFlags PLMENU_ALLOW_SELF) ? (id != iPlayer) : true) )    )
        {
            
menu_addtext(iMenuszPlayerName)
        }
        else
        {
            
formatex(szUserIdcharsmax(szUserId), "%d"get_user_userid(iPlayer))
            
menu_additem(iMenuszPlayerNameszUserId0)
        }
    }

    return 
iMenu
}

public 
PlayersMenuHandler_Sample(idiMenuiItem)
{
    if( 
iItem == MENU_EXIT )
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}

    new 
szUserId[32], szPlayerName[32], iPlayer
    menu_item_getinfo
(iMenuiItemiCRAPszUserIdcharsmax(szUserId), szPlayerNamecharsmax(szPlayerName), iPlayer /* tip */)

    if( (
iPlayer find_player("k"str_to_num(szUserId)))  )
    {
        new 
szName[32]
        
get_user_name(iPlayerszNamecharsmax(szName))
        
client_print(idprint_chat"You have chosen #%s %s %s"szUserIdszPlayerNameszName)
    }
    else
    {
        
client_print(idprint_chat"Player %s<%s> seems to be disconnected"szPlayerNameszAuthid)
    }
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-29-2012 at 07:44.
ConnorMcLeod is offline
paiNflCltch
Junior Member
Join Date: Sep 2012
Old 09-29-2012 , 07:53   Re: menu_display() issue
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
#define PLMENU_OBEY_IMMUNITY (1<<0)
#define PLMENU_ALLOW_SELF    (1<<1)
#define PLMENU_ONLY_ALIVE    (1<<2)
#define PLMENU_NO_BOTS        (1<<3)

MakePlayerMenu(id, const szMenuTitle[], const szMenuHandler[], iFlags PLMENU_OBEY_IMMUNITY)
{
    new 
iMenu menu_create(szMenuTitleszMenuHandler)
    new 
bool:bIsSuperAdmin
    
if( iFlags PLMENU_OBEY_IMMUNITY )
    {
        
bIsSuperAdmin = !!(get_user_flags(id) & ADMIN_RCON)
    }

    new 
iPlayers[32], iNumiPlayerszPlayerName[32], szUserId[32]
    new 
szFlags[4] = "h"
    
if( iFlags PLMENU_ONLY_ALIVE )
    {
        
szFlags[++iNum] = 'a'
    
}
    if( 
flags PLMENU_NO_BOTS )
    {
        
szFlags[++iNum] = 'c'
    
}

    
get_players(iPlayersiNumszFlags)

    for(--
iNumiNum>=0iNum--)
    {
        
iPlayer iPlayers[iNum]
        
get_user_name(iPlayerszPlayerNamecharsmax(szPlayerName))

        if(    
iFlags PLMENU_OBEY_IMMUNITY && !bIsSuperAdmin
        
&&    ( (get_user_flags(iPlayer) & ADMIN_IMMUNITY) && 
            ((
iFlags PLMENU_ALLOW_SELF) ? (id != iPlayer) : true) )    )
        {
            
menu_addtext(iMenuszPlayerName)
        }
        else
        {
            
formatex(szUserIdcharsmax(szUserId), "%d"get_user_userid(iPlayer))
            
menu_additem(iMenuszPlayerNameszUserId0)
        }
    }

    return 
iMenu
}

public 
PlayersMenuHandler_Sample(idiMenuiItem)
{
    if( 
iItem == MENU_EXIT )
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}

    new 
szUserId[32], szPlayerName[32], iPlayer
    menu_item_getinfo
(iMenuiItemiCRAPszUserIdcharsmax(szUserId), szPlayerNamecharsmax(szPlayerName), iPlayer /* tip */)

    if( (
iPlayer find_player("k"str_to_num(szUserId)))  )
    {
        new 
szName[32]
        
get_user_name(iPlayerszNamecharsmax(szName))
        
client_print(idprint_chat"You have chosen #%s %s %s"szUserIdszPlayerNameszName)
    }
    else
    {
        
client_print(idprint_chat"Player %s<%s> seems to be disconnected"szPlayerNameszAuthid)
    }
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED

I've the players menu done, I need to know what I must use in the case 2 to 7, cause the 1 case is the general selection.

Like if you choose the option 1 you will kick all players, but the next choice (2 to 7) are players, choice 1 works fine, but in "Target" I don't know what I must use to kick 1 player in the same menu.
Sorry for my english and thanks you for your support.
paiNflCltch 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 08:19.


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