Raised This Month: $ Target: $400
 0% 

Command in menu only for admin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kamild1996
Senior Member
Join Date: May 2011
Old 10-02-2011 , 05:00   Command in menu only for admin
Reply With Quote #1

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?
kamild1996 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-02-2011 , 07:02   Re: Command in menu only for admin
Reply With Quote #2

PHP Code:
menu_additem(MyMenu"Menu Admina""4"ADMIN_BAN
"4" stands for item 4.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
kamild1996
Senior Member
Join Date: May 2011
Old 10-02-2011 , 07:13   Re: Command in menu only for admin
Reply With Quote #3

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?
kamild1996 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-02-2011 , 07:16   Re: Command in menu only for admin
Reply With Quote #4

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.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
kamild1996
Senior Member
Join Date: May 2011
Old 10-02-2011 , 08:23   Re: Command in menu only for admin
Reply With Quote #5

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;
}
kamild1996 is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 10-02-2011 , 09:12   Re: Command in menu only for admin
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
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.
Erox902 is offline
kamild1996
Senior Member
Join Date: May 2011
Old 10-02-2011 , 10:19   Re: Command in menu only for admin
Reply With Quote #7

Quote:
Originally Posted by Erox902 View Post
Check the callbacks functions instead.
Uhm... How?
kamild1996 is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 10-02-2011 , 11:11   Re: Command in menu only for admin
Reply With Quote #8

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
Erox902 is offline
kamild1996
Senior Member
Join Date: May 2011
Old 10-02-2011 , 13:04   Re: Command in menu only for admin
Reply With Quote #9

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.
kamild1996 is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 10-02-2011 , 13:46   Re: Command in menu only for admin
Reply With Quote #10

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.
Erox902 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 19:36.


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