This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

New AMXX Menu System


Post New Thread Reply   
 
Thread Tools Display Modes
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 02-12-2010 , 19:47   Re: New AMXX Menu System
Reply With Quote #181

ill try explaining it better then :p

i want 3 pages displaying 27 items
i want to display 9 items on each page (from 1-9) with 0 being exit on each page
If i use this method, there wont be any way to navigate through the 3 pages so to get round this, i want to use a clcmd
the cmd will increment a variable[id]. If its 4, it will set it to 0 then it will show the menu on page variable[id]

so i do the cmd once and page 1 appears with 9 items on it. If i do the cmd again, it will switch to page 2, again will be page 3 and the 4th time i do the cmd it will go back to page 1


thats probably a really over complicated explaination but w/e...
__________________
minimiller is offline
Send a message via MSN to minimiller
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-12-2010 , 23:33   Re: New AMXX Menu System
Reply With Quote #182

Why not just create 3 separate menus?
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-13-2010 , 00:52   Re: New AMXX Menu System
Reply With Quote #183

Quote:
Originally Posted by Emp` View Post
Why not just create 3 separate menus?
This is what I was going to suggest.

@minimiller: I'll write up a quick example for you here in a bit.

EDIT:

An outline of what I'm refering to:
(I have it set up for non-changing menus. If you need dynamic menus you will need to create them and destroy them.)

PHP Code:
new g_pPage[3]
new 
g_iPlayerPage[33]

public 
plugin_init()
{
    
register_clcmd("say /menu""cmdMenu")
    
    new 
pPage
    
// Create page 1
    
pPage g_pPage[0]
    
pPage menu_create(/*...*/)
    
/*
    . . . data 1 through 9
    */
    
    // Create page 2
    
pPage g_pPage[1]
    
pPage menu_create(/*...*/)
    
/*
    . . . data 10 through 18
    */
    
    // Create page 3
    
pPage g_pPage[2]
    
pPage menu_create(/*...*/)
    
/*
    . . . data 19 through 27
    */
}

public 
cmdMenu(id)
{
    
menu_display(idg_pPage[g_iPlayerPage[id]])
    
g_iPlayerPage[id] = (g_iPlayerPage[id] + 1) % sizeof(g_pPage)
}

// All menus can use this handler.
public menu_handler(idmenuitem)
{
    
// ... retrieve data and such
    
    
switch(key)
    {
        case 
1// stuff for page 1 option 1
        // ...
        
case 10// stuff for page 2 option 1
        // ...
        
case 19// stuff for page 3 option 1
        // ...
    
}
    
    
// Do not destroy menu if it remains global :).

__________________

Last edited by fysiks; 02-13-2010 at 01:31.
fysiks is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 02-13-2010 , 13:51   Re: New AMXX Menu System
Reply With Quote #184

awesome work fysiks. worked like a charm

and the reason i didnt want to make 2 menus was bacuase i thought it would be easier to handle everything using just 1 menu

ths again for every1s help (Y)
__________________
minimiller is offline
Send a message via MSN to minimiller
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 02-14-2010 , 03:17   Re: New AMXX Menu System
Reply With Quote #185

i created this menu for my jb server, it should be easier for admins to use gag, could you guys take a look and tell me what you think?
It's not tested yet, want to hear you guys about it first.
compiles without errors or warnings.

PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_clcmd"say /gag","gag_mainmenu"ADMIN_KICK);
}

public 
gag_mainmenu(idiLeveliCid)
{
    if(!
cmd_access(idiLeveliCid2))
    {
        
client_print(idprint_chat"Only admins can gag players")
        return 
PLUGIN_HANDLED;
    }
    
    new 
gagmainmenu menu_create("\rGag menu""sub_gag_mainmenu");
    
    
menu_additem(gagmainmenu"\wGag a player""1"0);
    
menu_additem(gagmainmenu"\wUngag a player""2"0);
    
    
menu_setprop(gagmainmenuMPROP_EXITMEXIT_ALL);
    
    
menu_display(idgagmainmenu0);
    
    return 
PLUGIN_CONTINUE
}

public 
sub_gag_mainmenu(idgagmainmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(gagmainmenu);
        
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(gagmainmenuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            
gag_optionmenu(id)
        }
        case 
2:
        {
            
player_ungag_menu(id)
        }
    }
    
menu_destroy(gagmainmenu);
    return 
PLUGIN_HANDLED;
}


gag_optionmenu(id)
{
    new 
gagoptionmenu menu_create("\rGag how?:""sub_gag_optionmenu")

    
menu_additem(gagoptionmenu"\wGag Chat""1"0);
    
menu_additem(gagoptionmenu"\wGag teamchat""2"0);
    
menu_additem(gagoptionmenu"\wGag all chat""3"0)
    
menu_additem(gagoptionmenu"\wGag voicecomm""4"0)
    
menu_additem(gagoptionmenu"\wGag all""5"0)

    
menu_setprop(gagoptionmenuMPROP_EXITMEXIT_ALL);
    
menu_display(idgagoptionmenu0);
}
public 
sub_gag_optionmenu(idgagoptionmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(gagoptionmenu);

        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(gagoptionmenuitemaccessdata,5iName63callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
            
player_gag_menu_chat(id)
        }
        case 
2:
        {
            
player_gag_menu_tchat(id)
        }
        case 
3:
        {
            
player_gag_menu_allchat(id)
        }
        case 
4:
        {
            
player_gag_menu_voice(id)
        }
        case 
5:
        {
            
player_gag_menu_all(id)
        }
        
    }

    
menu_destroy(gagoptionmenu);

    return 
PLUGIN_HANDLED;
}

public 
player_ungag_menu(id)
{
    new 
playerungagmenu menu_create("\rUngag who?:""sub_player_ungag_menu");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);
        
        
menu_additem(playerungagmenuszNameszTempid0);
    }
    
menu_display(idplayerungagmenu0);
}

public 
sub_player_ungag_menu(idplayerungagmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(playerungagmenu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(playerungagmenuitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
console_cmd(id"amx_ungag %s"tempid)
    
client_print(0print_chat"player %s is no longer gagged"tempid
    
    
menu_destroy(playerungagmenu);
    return 
PLUGIN_HANDLED;
}

public 
player_gag_menu_chat(id)
{
    new 
playergagmenuchat menu_create("\rGag who?:""sub_player_gag_menu_chat");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);
        
        
menu_additem(playergagmenuchatszNameszTempid0);
        
    }
    
menu_display(idplayergagmenuchat0);
}

public 
sub_player_gag_menu_chat(idplayergagmenuchatitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(playergagmenuchat);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(playergagmenuchatitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
menu_destroy(playergagmenuchat);
    
console_cmd(id"amx_gag %s 99999999 a"tempid)
    
client_print(0print_chat"player %s is gagged on chat"tempid
    
    return 
PLUGIN_HANDLED;
}

public 
player_gag_menu_tchat(id)
{
    new 
playergagmenutchat menu_create("\rGag who?:""sub_player_gag_menu_tchat");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);
        
        
menu_additem(playergagmenutchatszNameszTempid0);
        
    }
    
menu_display(idplayergagmenutchat0);
}

public 
sub_player_gag_menu_tchat(idplayergagmenutchatitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(playergagmenutchat);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(playergagmenutchatitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
menu_destroy(playergagmenutchat);
    
console_cmd(id"amx_gag %s 99999999 b"tempid)
    
client_print(0print_chat"player %s is gagged on team chat"tempid
    
    return 
PLUGIN_HANDLED;
}

public 
player_gag_menu_allchat(id)
{
    new 
playergagmenuallchat menu_create("\rGag who?:""sub_player_gag_menu_allchat");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);
        
        
menu_additem(playergagmenuallchatszNameszTempid0);
        
    }
    
menu_display(idplayergagmenuallchat0);
}

public 
sub_player_gag_menu_allchat(idplayergagmenuallchatitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(playergagmenuallchat);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(playergagmenuallchatitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
menu_destroy(playergagmenuallchat);
    
console_cmd(id"amx_gag %s 99999999 ab"tempid)
    
client_print(0print_chat"player %s is gagged on all chat"tempid
    
    return 
PLUGIN_HANDLED;
}

public 
player_gag_menu_voice(id)
{
    new 
playergagmenuvoice menu_create("\rGag who?:""sub_player_gag_menu_voice");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);
        
        
menu_additem(playergagmenuvoiceszNameszTempid0);
        
    }
    
menu_display(idplayergagmenuvoice0);
}

public 
sub_player_gag_menu_voice(idplayergagmenuvoiceitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(playergagmenuvoice);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(playergagmenuvoiceitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
menu_destroy(playergagmenuvoice);
    
console_cmd(id"amx_gag %s 99999999 c"tempid)
    
client_print(0print_chat"player %s is gagged on voicecomm"tempid
    
    return 
PLUGIN_HANDLED;
}

public 
player_gag_menu_all(id)
{
    new 
playergagmenuall menu_create("\rGag who?:""sub_player_gag_menu_all");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);
        
        
menu_additem(playergagmenuallszNameszTempid0);
        
    }
    
menu_display(idplayergagmenuall0);
}

public 
sub_player_gag_menu_all(idplayergagmenuallitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(playergagmenuall);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(playergagmenuallitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data);
    
    
menu_destroy(playergagmenuall);
    
console_cmd(id"amx_gag %s 99999999 abc"tempid)
    
client_print(0print_chat"player %s is gagged on all chat and voicecomm"tempid
    
    return 
PLUGIN_HANDLED;

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 02-14-2010 , 03:44   Re: New AMXX Menu System
Reply With Quote #186

I want to know how to set 8 items per page ? I tried with this
Code:
menu_setprop ( Menu, MPROP_PERPAGE, 8 )
but it gives run-time error and says that cannot create 8 items per page.
__________________


Last edited by NiHiLaNTh; 02-14-2010 at 05:54.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 02-14-2010 , 11:23   Re: New AMXX Menu System
Reply With Quote #187

Quote:
Originally Posted by NiHiLaNTh View Post
I want to know how to set 8 items per page ? I tried with this
Code:
menu_setprop ( Menu, MPROP_PERPAGE, 8 )
but it gives run-time error and says that cannot create 8 items per page.
Quote:
Originally Posted by SnoW View Post
Setting MPROP_PERPAGE to zero sets paginating off.
SnoW is offline
Send a message via MSN to SnoW
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 02-14-2010 , 14:50   Re: New AMXX Menu System
Reply With Quote #188

Thank you very much
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-14-2010 , 17:02   Re: New AMXX Menu System
Reply With Quote #189

Quote:
Originally Posted by drekes View Post
i created this menu for my jb server, it should be easier for admins to use gag, could you guys take a look and tell me what you think?
It's not tested yet, want to hear you guys about it first.
compiles without errors or warnings.
Try it and you tell us if it's working or not.

Quote:
Originally Posted by NiHiLaNTh View Post
I want to know how to set 8 items per page ? I tried with this
Code:
menu_setprop ( Menu, MPROP_PERPAGE, 8 )
but it gives run-time error and says that cannot create 8 items per page.
You can't.

@Snow, that doesn't actually solve the problem unless he doesn't actually want "pages". When I read the question I interpreted it as him still wanting pages.
__________________
fysiks is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 02-15-2010 , 09:28   Re: New AMXX Menu System
Reply With Quote #190

Quote:
Originally Posted by fysiks View Post
@Snow, that doesn't actually solve the problem unless he doesn't actually want "pages". When I read the question I interpreted it as him still wanting pages.
His message says that he wants pages but with thinking the issue I came to the right conclusion.

Note that if someone really wants eight items with pages it's possible but then you can't choose an exit item.
SnoW is offline
Send a message via MSN to SnoW
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 03:39.


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