AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Command in menu only for admin (https://forums.alliedmods.net/showthread.php?t=168648)

kamild1996 10-02-2011 05:00

Command in menu only for admin
 
Hi.
I have a problem (again...). I have this code:
Quote:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Menu serwera"
#define VERSION "1.0"
#define AUTHOR "Redux"

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /menu","mymenu");
}

public client_connect(id)
{
client_cmd(id, "bind v say /menu")
}

public mymenu(id)
{
new MyMenu=menu_create("\wMenu serwera [\rDeathrun\w]","cbMyMenu");

menu_additem(MyMenu,"Zmien serwer");//item=0
menu_additem(MyMenu,"Sklep DR");//item=1
menu_additem(MyMenu,"Wylacz widocznosc CT");//item=2
menu_additem(MyMenu,"Punkty");//item=3
menu_additem(MyMenu,"Menu Admina");//item=4
menu_additem(MyMenu,"Wylacz/wlacz RS");//item=5

menu_setprop(MyMenu,MPROP_EXITNAME,"Wyjscie") ;
menu_setprop(MyMenu,MPROP_EXIT,MEXIT_ALL);
menu_setprop(MyMenu,MPROP_NUMBER_COLOR,"\y");


menu_display(id, MyMenu,0);
return PLUGIN_HANDLED;
}
public cbMyMenu(id, menu, item)
{
switch(item)
{
case 0:
{
client_cmd(id, "say /serwer");

}
case 1:
{
client_cmd(id, "say /drshop");

}
case 2:
{
client_cmd(id, "say /invis");

}
case 3:
{
client_cmd(id, "say /mypoints");

}
case 4:
{
client_cmd(id, "amxmodmenu");

}
case 5:
{
client_cmd(id, "say /roundsound");

}

}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
I want this command:
Quote:

menu_additem(MyMenu,"Menu Admina");//item=4
be avaliable to choose only for players with ADMIN_BAN flag. Can you explain me, step by step, how to add this function?

Napoleon_be 10-02-2011 07:02

Re: Command in menu only for admin
 
PHP Code:

menu_additem(MyMenu"Menu Admina""4"ADMIN_BAN

"4" stands for item 4.

kamild1996 10-02-2011 07:13

Re: Command in menu only for admin
 
So I must replace
Quote:

menu_additem(MyMenu,"Menu Admina");//item=4
with:
Quote:

menu_additem(MyMenu, "Menu Admina", "4", ADMIN_BAN)
and it's all?

Napoleon_be 10-02-2011 07:16

Re: Command in menu only for admin
 
Yes, just replace this with yours:
PHP Code:


    menu_additem
(MyMenu,"Zmien serwer""1"id)
    
menu_additem(MyMenu,"Sklep DR""2"id)
    
menu_additem(MyMenu,"Wylacz widocznosc CT""3"id)
    
menu_additem(MyMenu,"Punkty""4"id)
    
menu_additem(MyMenu,"Menu Admina""5"ADMIN_BAN)
    
menu_additem(MyMenu,"Wylacz/wlacz RS""6"id

Use for Number one of the menu, case 0 if you're going to do it like that.

kamild1996 10-02-2011 08:23

Re: Command in menu only for admin
 
Now the whole menu is grey, only "Exit" is chooseable. For admins - all is OK. There is something wrong?
Quote:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Menu serwera"
#define VERSION "1.0"
#define AUTHOR "Redux"

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /menu","mymenu");
}

public client_connect(id)
{
client_cmd(id, "bind v say /menu")
}

public mymenu(id)
{
new MyMenu=menu_create("\wMenu serwera \d[\rDeathrun\d]","cbMyMenu");

menu_additem(MyMenu,"Zmien serwer", "1", id)
menu_additem(MyMenu,"Sklep DR", "2", id)
menu_additem(MyMenu,"Wylacz widocznosc CT", "3", id)
menu_additem(MyMenu,"Punkty", "4", id)
menu_additem(MyMenu,"Menu Admina", "5", ADMIN_BAN)
menu_additem(MyMenu,"Wylacz/wlacz RS", "6", id)

menu_setprop(MyMenu,MPROP_EXITNAME,"Wyjscie") ;
menu_setprop(MyMenu,MPROP_EXIT,MEXIT_ALL);
menu_setprop(MyMenu,MPROP_NUMBER_COLOR,"\y");


menu_display(id, MyMenu,0);
return PLUGIN_HANDLED;
}
public cbMyMenu(id, menu, item)
{
switch(item)
{
case 0:
{
client_cmd(id, "say /serwer");

}
case 1:
{
client_cmd(id, "say /drshop");

}
case 2:
{
client_cmd(id, "say /invis");

}
case 3:
{
client_cmd(id, "say /mypoints");

}
case 4:
{
client_cmd(id, "amxmodmenu");

}
case 5:
{
client_cmd(id, "say /roundsound");

}

}
menu_destroy(menu);
return PLUGIN_HANDLED;
}

Erox902 10-02-2011 09:12

Re: Command in menu only for admin
 
Quote:

Originally Posted by Napoleon_be (Post 1566996)
Yes, just replace this with yours:
PHP Code:


    menu_additem
(MyMenu,"Zmien serwer""1"id)
    
menu_additem(MyMenu,"Sklep DR""2"id)
    
menu_additem(MyMenu,"Wylacz widocznosc CT""3"id)
    
menu_additem(MyMenu,"Punkty""4"id)
    
menu_additem(MyMenu,"Menu Admina""5"ADMIN_BAN)
    
menu_additem(MyMenu,"Wylacz/wlacz RS""6"id

Use for Number one of the menu, case 0 if you're going to do it like that.

Check the callbacks functions instead.

kamild1996 10-02-2011 10:19

Re: Command in menu only for admin
 
Quote:

Originally Posted by Erox902 (Post 1567049)
Check the callbacks functions instead.

Uhm... How?

Erox902 10-02-2011 11:11

Re: Command in menu only for admin
 
You click the search button and enter "menu_makecallback"(without quotes)
Or you can lookup the function "menu_makecallback()" in the funcwiki.
Or even look it up in the Snippets/tutorial section.

I do however recommend the search or snippets way since there they usually have simple examples to ensure that you do it right :)

kamild1996 10-02-2011 13:04

Re: Command in menu only for admin
 
I found this in funcwiki (I can't find it in forum):
Quote:

menu_makecallback ( function[] )
So, what to do with it?

Sorry, i'm beginner.

Erox902 10-02-2011 13:46

Re: Command in menu only for admin
 
Well then you obviously didn't check the tutorial section, I'm 100% sure you've already been in the right tread.
I think you should be able to guess this right away since it's about menus.
When I've been helpfull enough to post all links and tell you what function to use i atleast expect you to search through them.


All times are GMT -4. The time now is 19:35.

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