Raised This Month: $ Target: $400
 0% 

Multiple menus and handlers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 04-30-2011 , 05:54   Multiple menus and handlers
Reply With Quote #1

Hey, I'm going to create a plugin with 10+ menus, like this:

Menu with actions:
*Ban menu
*Kick menu
*Mute menu
*..
*..
*..
*..

Like lets take
[ban action menu]:
1. Choose a player to ban.
2. Choose a banreason.
3. Choose a bantime.
4. Accept all settings and ban player.

[kick action menu]:
1. Choose a player to kick.
2. Choose a kickreason.
3. Accept all settings and kick player.

[mute action menu]:
1. Choose a player to mute.
2. Choose a mutereason.
3. Choose a mutetime.
4. Accept all settings and mute player.

Is there another way, instead of making 11 menus & menu handlers ?
Instead of having 3 same menu with players listed there should be other way.

I would like something like
-ActionMenu -PlayerMenu -ReasonMenu -TimeMenu (if needed) -Accept action menu.

Last edited by reinert; 04-30-2011 at 06:12.
reinert is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-30-2011 , 07:06   Re: Multiple menus and handlers
Reply With Quote #2

Using global variables and logic you can use one menu hook to create many different menus... at least by using classic menu system.

You'll have some problems, like undetected closed menus and stuff... but hey, if you really want one menu handle, you'll have to face it
__________________
Hunter-Digital is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 04-30-2011 , 08:27   Re: Multiple menus and handlers
Reply With Quote #3

Would be very thankful if anyone could give me example or smth useful ;Dp
reinert is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-30-2011 , 09:07   Re: Multiple menus and handlers
Reply With Quote #4

[ZP] Addon: CS-like_Buymenu
__________________

SonicSonedit is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 04-30-2011 , 11:10   Re: Multiple menus and handlers
Reply With Quote #5

Something like this ?


PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define MAXOPTIONS 6

new menu_players
new menu_actions

new g_maxplayers

new const ActionMenu[MAXOPTIONS][] = {
    
"Ban menu",
    
"Kick menu",
    
"Mute menu",
    
"Slay menu",
    
"Warn menu",
    
""
}

new const 
BanReasons[MAXOPTIONS][] = {
    
"Use of 3rd party programs (Cheating)",
    
"Disrespection for players or admins (Harassment)",
    
"Use of abusive language (Swearing)",
    
"Omission of given task (Hostages, Defuse, Plant)",
    
"Team prevention (Blocking, Flashing)",
    
"Other..."
}

new const 
BanTime[MAXOPTIONS][] = {
    
"30 minutes",
    
"1 hour",
    
"3 hours",
    
"12 hours",
    
"1 day",
    
"1 week"
}


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("/adminmenu""CmdPlayerMenu")
    
    
menu_players menu_create("""")
    
menu_actions menu_create("""")
    
    
g_maxplayers get_maxplayers()
}

public 
CmdPlayerMenu(id)
{
    static 
iname[32]
    
    
menu_destroy(menu_players)
    
menu_players menu_create("Player Menu""playermenu_handle")
    for (
i=1i<=g_maxplayersi++)
    {
        if (!
is_user_connected(i))
            continue
            
        
get_user_name(inamecharsmax(name))
        
menu_additem(menu_playersnamename)
    }
    
menu_display(idmenu_players)
    
    return 
PLUGIN_HANDLED;
}

public  
playermenu_handle(idmenuitem)
{
    static 
name[32], dummy

    menu_item_getinfo
(menuitemdummynamecharsmax(name), __dummy)
    
    
CmdActionMenu(id)
}

public 
CmdActionMenu(id)
{
    static 
i;
    
    
menu_destroy(menu_actions)
    
menu_actions menu_create("Actions Menu""actionmenu_handle")
    for (
i=1i<=MAXOPTIONS-1i++)
    {
        
menu_additem(menu_actionsActionMenu[i][i])
    }
    
menu_display(idmenu_actions)
    
    return 
PLUGIN_HANDLED;
}

public  
actionmenu_handle(idmenuitem)
{
    static 
name[32], dummy

    menu_item_getinfo
(menuitemdummynamecharsmax(name), __dummy)
    
    
//CmdActionMenu(id)

I've created Player menu, then Action menu what should I do now ?
reinert is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-30-2011 , 18:06   Re: Multiple menus and handlers
Reply With Quote #6

Ok, I did most of the infrastructure for you:

Also, when doing the player menu, use this.
Attached Files
File Type: sma Get Plugin or Get Source (admin_menu_reinert.sma - 507 views - 4.6 KB)
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 04:21.


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