AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with adminmenu (https://forums.alliedmods.net/showthread.php?t=101659)

Zapdos1 08-25-2009 22:05

Help with adminmenu
 
well, when i write say /adminmenu
the menu doesn't appear.
plz help.

PHP Code:


new mAdminMenu 
new maxplayers
new g_iMaxPlayers
new mcbAdminMenu

public plugin_init()
{
          
register_clcmd("say /adminmenu","adminmenu",ADMIN_MENU"Show adminmenu")
          
register_clcmd("say_team /adminmneu""adminmenu"ADMIN_MENU"Show adminmenu")
          
register_concmd("adminmenu""adminmenu"ADMIN_MENU"Show adminmenu")
}

public 
adminmenu(id
{
    for( new 
1<= g_iMaxPlayers i++ )
    {
        if( 
is_user_admin(i) )
            
        
mAdminMenu menu_create("admin menu""mh_AdminMenu")
        
menu_additem(mAdminMenu"\Changelevel""1"ADMIN_MENUmcbAdminMenu)
        
menu_additem(mAdminMenu"\Change to Allied""2"ADMIN_MENUmcbAdminMenu)
        
menu_additem(mAdminMenu"\Change to Soviet""3"ADMIN_MENUmcbAdminMenu)
        
menu_additem(mAdminMenu"\Restart Server""4"ADMIN_MENUmcbAdminMenu)
        
        
menu_setprop(mAdminMenu,MPROP_EXITNAME,"Salir")
        
menu_setprop(mAdminMenuMPROP_EXITMEXIT_ALL)
    }
}

public 
mh_AdminMenu(idmenuitem
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(mAdminMenu)
        return 
PLUGIN_HANDLED
    

    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(mAdminMenuitemiAccessiData5iName63iCallback)
    
    switch (
str_to_num(iData))
    { 
        case 
1:
        {
            
server_cmd("changelevel  de_dust2")
        }
        case 
2:
        {
            
Allied(id)
        }
        case 
3:
        {
            
Soviet(id)
        }
        case 
4:
        {
            
restartmenu(id)
        }
        
    }
    
    return 
PLUGIN_HANDLED


public 
Allied(id)
{
    new 
temp1[32]
    new 
temp2[2]
    new 
Menu menu_create("Players:","handle")  
    
    for (new 
1<= maxplayersi++){
        if (
is_user_connected(i))
        {
            
get_user_name(i,temp1,32);
            
num_to_str(i,temp2,2);
            
menu_additem(Menutemp1,temp2);
        }
    }
    
menu_display(idMenu0);  
}

public 
handle(idMenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(MenuitemiAccessiData5iName63iCallback)
    
    if(
cs_get_user_team(id) == CS_TEAM_T)
    {
        
cs_set_user_team(idCS_TEAM_CT)
    }
    return 
PLUGIN_HANDLED
}  

public 
Soviet(id)
{
    new 
temp1[32]
    new 
temp2[2]
    new 
Menu menu_create("Players:","handles")  
    
    for (new 
1<= maxplayersi++){
        if (
is_user_connected(i))
        {
            
get_user_name(i,temp1,32);
            
num_to_str(i,temp2,2);
            
menu_additem(Menutemp1,temp2);
        }
    }
    
menu_display(idMenu0);  
}

public 
handles(idMenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(MenuitemiAccessiData5iName63iCallback)
    
    if(
cs_get_user_team(id) == CS_TEAM_CT)
    {
        
cs_set_user_team(idCS_TEAM_T)
    }
    
    return 
PLUGIN_HANDLED
}  

public 
restartmenu(id)
{
    new 
restart menu_create("\wEscoja el tiempo de restart""mostrar_menu"
    
menu_additem(restart"\1 Segundo"            "1"0
    
menu_additem(restart"\5 Segundos"    "2"0
    
menu_additem(restart"\10 Segundos"            "3"0
    
    
menu_setprop(restartMPROP_EXITMEXIT_ALL)
    
menu_display(idrestart0)


public 
mostrar_menu(idrestartitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(restart)
        return 
PLUGIN_HANDLED
    

    
    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(restartitemiAccessiData5iName63iCallback
    
    switch (
str_to_num(iData))
    { 
        case 
1:
        {
            
server_cmd("sv_restart 1")
        }
        case 
2:
        {
            
server_cmd("sv_restart 5")
        }
        case 
3
        {
            
server_cmd("sv_restart 10")
        }
        
    }
    
    return 
PLUGIN_HANDLED


plz help.

meTaLiCroSS 08-25-2009 22:11

Re: Help with adminmenu
 
menu_display(i, mAdminMenu, 0)

Zapdos1 08-25-2009 22:16

Re: Help with adminmenu
 
thanks, but i tested and nothing yet :S

meTaLiCroSS 08-25-2009 22:47

Re: Help with adminmenu
 
Quote:

Originally Posted by Zapdos1 (Post 913111)
thanks, but i tested and nothing yet :S

PHP Code:

for( new 1<= g_iMaxPlayers i++ ) 

Why that Loop?

fysiks 08-25-2009 23:56

Re: Help with adminmenu
 
Try this and see what happens:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new maxplayers

public plugin_init()
{
    
register_clcmd("say /adminmenu","adminmenu",ADMIN_MENU"Show adminmenu")
    
register_clcmd("say_team /adminmneu""adminmenu"ADMIN_MENU"Show adminmenu")
    
register_concmd("adminmenu""adminmenu"ADMIN_MENU"Show adminmenu")
}

public 
adminmenu(id,level,cid)
{
    if(!
cmd_access(id,level,cid,1))
    {
        return 
PLUGIN_HANDLED
    
}

    new 
mAdminMenu menu_create("admin menu""mh_AdminMenu")
    
menu_additem(mAdminMenu"\Changelevel""1")
    
menu_additem(mAdminMenu"\Change to Allied""2")
    
menu_additem(mAdminMenu"\Change to Soviet""3")
    
menu_additem(mAdminMenu"\Restart Server""4")

    
menu_setprop(mAdminMenu,MPROP_EXITNAME,"Salir")
    
menu_setprop(mAdminMenuMPROP_EXITMEXIT_ALL)

    
menu_display(idmAdminMenu0)

    return 
PLUGIN_HANDLED
}

public 
mh_AdminMenu(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}

    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(menuitemiAccessiData5iName63iCallback)

    switch (
str_to_num(iData))
    {
        case 
1:
        {
            
server_cmd("changelevel de_dust2")
        }
        case 
2:
        {
            
Allied(id)
        }
        case 
3:
        {
            
Soviet(id)
        }
        case 
4:
        {
            
restartmenu(id)
        }

    }

    return 
PLUGIN_HANDLED
}

public 
Allied(id)
{
    new 
temp1[32]
    new 
temp2[2]
    new 
Menu menu_create("Players:","handle")

    for (new 
1<= maxplayersi++){
        if (
is_user_connected(i))
        {
            
get_user_name(i,temp1,32);
            
num_to_str(i,temp2,2);
            
menu_additem(Menutemp1,temp2);
        }
    }
    
menu_display(idMenu0);
}

public 
handle(idMenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}

    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(MenuitemiAccessiData5iName63iCallback)

    if(
cs_get_user_team(id) == CS_TEAM_T)
    {
        
cs_set_user_team(idCS_TEAM_CT)
    }
    return 
PLUGIN_HANDLED
}

public 
Soviet(id)
{
    new 
temp1[32]
    new 
temp2[2]
    new 
Menu menu_create("Players:","handles")

    for (new 
1<= maxplayersi++){
        if (
is_user_connected(i))
        {
            
get_user_name(i,temp1,32);
            
num_to_str(i,temp2,2);
            
menu_additem(Menutemp1,temp2);
        }
    }
    
menu_display(idMenu0);
}

public 
handles(idMenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}

    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(MenuitemiAccessiData5iName63iCallback)

    if(
cs_get_user_team(id) == CS_TEAM_CT)
    {
        
cs_set_user_team(idCS_TEAM_T)
    }

    return 
PLUGIN_HANDLED
}

public 
restartmenu(id)
{
    new 
restart menu_create("\wEscoja el tiempo de restart""mostrar_menu")
    
menu_additem(restart"\1 Segundo"            "1"0)
    
menu_additem(restart"\5 Segundos"    "2"0)
    
menu_additem(restart"\10 Segundos"            "3"0)

    
menu_setprop(restartMPROP_EXITMEXIT_ALL)
    
menu_display(idrestart0)
}

public 
mostrar_menu(idrestartitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(restart)
        return 
PLUGIN_HANDLED
    
}

    new 
iData[6];
    new 
iAccess;
    new 
iCallback;
    new 
iName[64];
    
menu_item_getinfo(restartitemiAccessiData5iName63iCallback)

    switch (
str_to_num(iData))
    {
        case 
1:
        {
            
server_cmd("sv_restart 1")
        }
        case 
2:
        {
            
server_cmd("sv_restart 5")
        }
        case 
3:
        {
            
server_cmd("sv_restart 10")
        }

    }

    return 
PLUGIN_HANDLED



Zapdos1 08-26-2009 22:46

Re: Help with adminmenu
 
@ fysiks:

thanks it works :D.

but i have a little problem.

all the options say
hangledchangelevel
hangledallied
hangledsoviet
estart server

plz help, if you need a screenshot, only post here.

fysiks 08-27-2009 00:18

Re: Help with adminmenu
 
Get rid of the backslashes in the options strings.

BOYSplayCS 08-27-2009 09:38

Re: Help with adminmenu
 
Adding the backslashes tells the plugin that you are trying to add colors into the menu items.

You define colors by the '\' symbol when using menus, for example: \r creates red and /y will create yellow. In your code, for example, you added "\Changelevel" which makes the plugin recognize "\C" as an invalid color option. The reason it is invalid is because the C is capitalized and AMXX will only recognize lower-case letters.

zacky 08-27-2009 11:18

Re: Help with adminmenu
 
Quote:

Originally Posted by BOYSplayCS (Post 914357)
You define colors by the '\' symbol when using menus, for example: \r creates red and /y will create yellow. In your code, for example, you added "\Changelevel" which makes the plugin recognize "\C" as an invalid color option.

Fail? xD

xPaw 08-27-2009 11:25

Re: Help with adminmenu
 
say_team /adminmneu -> say_team /adminmenu

register_concmd -> register_clcmd
We dont want allow menu for server console right ?


All times are GMT -4. The time now is 15:00.

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