Hi guys. It's my first post here and I'm little uneasy. I'm trying to create a slaymenu, but I can't make it for admins only (access level 3). Ok I'm using kickmenu code from this forum (code from somebody here) and I can't make it to works only for admins ! I don't know why but if write the commnand
amx_slaymenu and I'm not admin show me in console "you don't have an access to this command" (or something like this) and it's shows the menu... If I'm admin, doesn't show the message, but doesn't show the menu too, pff. I'm little confused about this. So I need you help :]] The code is not very good, but I think with your help I'll optimize it
p.s. I'm sorry about my poor english, but isn't my native !
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#define PLUGIN "SlayMenu"
#define VERSION "5.1"
#define AUTHOR "beBoss"
new p_menu
public plugin_init( )
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd( "amx_slaymenu", "showmenu", ADMIN_SLAY );
}
// beBoss CallBack
public beBossCallback(id, Menu, item)
{
return get_pcvar_num( p_menu ) ? ITEM_ENABLED : ITEM_DISABLED;
}
//public AccsessMenu( const id, const level, const cid )
//{
// if( cmd_access( id, level, cid, 3 ) )
// showmenu( id );
//
//}
public showmenu( const id, const level, const cid )
{
if( !cmd_access( id, level, cid, 3) )
return PLUGIN_HANDLED;
new menu = menu_create( "\yChoose a player to slay:", "submenu" );
new players[ 32 ], pnum, tempid;
new szName[ 32 ], szTempid[ 10 ];
get_players( players, pnum, "a" );
p_menu = register_cvar("p_menu", "0")
for( new i; i< pnum; i++ )
{
tempid = players[ i ];
get_user_name( tempid, szName, 31 );
num_to_str( tempid, szTempid, 9 );
if( !is_user_admin( tempid ) ) {
menu_additem(menu, szName, szTempid, 0) // if isn't admin = enabled
} else {
menu_additem(menu, szName, szTempid, 0, menu_makecallback("beBossCallback")) // if is admin = disabled
}
}
menu_display( id, menu );
return PLUGIN_HANDLED;
}
public submenu( const id, const menu, const item )
{ // ако е натиснато 0
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new data[ 6 ], iName[ 64 ];
new access, callback;
menu_item_getinfo( menu, item, access, data,5, iName, 63, callback );
new tempid = str_to_num( data );
if( !is_user_admin( tempid ) )
user_kill( tempid );
menu_destroy( menu );
return PLUGIN_HANDLED;
}
__________________