AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   access level problem (https://forums.alliedmods.net/showthread.php?t=135359)

beBoss 08-15-2010 10:06

access level problem
 
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(PLUGINVERSIONAUTHOR);
    
register_clcmd"amx_slaymenu""showmenu"ADMIN_SLAY );
}

    
// beBoss CallBack
public beBossCallback(idMenuitem

    return 
get_pcvar_nump_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_accessidlevelcid3) )
        return 
PLUGIN_HANDLED;
    
    new 
menu menu_create"\yChoose a player to slay:""submenu" );

    new 
players32 ], pnumtempid;
    new 
szName32 ], szTempid10 ];

    
get_playersplayerspnum"a" );

    
p_menu register_cvar("p_menu""0")
    
    for( new 
iipnumi++ )
    {
        
tempid players];
        
        
get_user_nametempidszName31 );
        
num_to_strtempidszTempid);
        
    
    if( !
is_user_admintempid ) ) { 
        
menu_additem(menuszNameszTempid0// if isn't admin = enabled
    
} else { 
        
menu_additem(menuszNameszTempid0menu_makecallback("beBossCallback")) // if is admin = disabled
    
}
    }
    
    
menu_displayidmenu );
    return 
PLUGIN_HANDLED;
    
}


    
public 
submenu( const id, const menu, const item )
{    
// ако е натиснато 0
    
if( item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }

    new 
data], iName64 ];
    new 
accesscallback;
    
menu_item_getinfomenuitemaccessdata,5iName63callback );

    new 
tempid str_to_numdata );

    if( !
is_user_admintempid ) )
        
user_killtempid );
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;



SaM.ThE.MaN 08-15-2010 15:45

Re: access level problem
 
when ur not an admin .. it says u dont have access to this command ... and am kinda busy to help u with the other part , anyways i kinda forgot 90% of what i really knew cause i was away for 2 months

fysiks 08-15-2010 17:34

Re: access level problem
 
You need to understand what that 3 does. It says that it needs three arguments (including the command name). So, you should only have a 1 there. So, if you just type in "amx_slaymenu" in your console it shouldn't show it to anyone.

ADMIN_SLAY is the access level that the function is using.

beBoss 08-16-2010 07:07

Re: access level problem
 
Ok, thanks for your help. Another question:

Quote:

Warning: Loose indentation on line 30
What does it mean ?

PHP Code:

25 public beBossMenu( const id, const level, const cid )
26 {
27    if( !cmd_accessidlevelcid1) )
28        return PLUGIN_HANDLED;
29    
30    
new menu menu_create"\yChoose a player to slay:""beBossSubMenu" );
31
32    
new players32 ], pnumtempid;
33    new szName32 ], szTempid10 ];
34
35    get_players
playerspnum"a" );
36
37    b_menu 
register_cvar("b_menu""0"); // for CallBack 


SpeeDeeR 08-16-2010 07:12

Re: access level problem
 
Its nothing to worry about.It doesnt affect the code.If your using amxx editor CTRL+I to use the Indenter tool.

beBoss 08-16-2010 07:31

Re: access level problem
 
Thank you SpeeDeeR. With Ctrl+I everything came to the place! By the way Благодаря !

Arkshine 08-16-2010 07:44

Re: access level problem
 
You should not rely on such tool if you don't understand what mean indentation. http://en.wikipedia.org/wiki/Indent_style

beBoss 08-16-2010 08:04

Re: access level problem
 
I understand it very well. I have experience in programming, just dоn't know that, the software has this option!


All times are GMT -4. The time now is 21:55.

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