Raised This Month: $ Target: $400
 0% 

[SOLVED] How to make this admin only...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 04-27-2009 , 10:29   [SOLVED] How to make this admin only...
Reply With Quote #1

!!! SOLVED !!!

Well guys...

I made this script...

But the problem is that i did ADMIN_MENU in clcmd, but its still for players...
How to fix?

PHP Code:
#include <amxmodx>
#include <fakemeta_util>
#define PLUGIN "WeaponMenu"
#define AUTHOR "GameFreak"
#define VERSION "1.0"
 
public plugin_init()
 {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd"say /weapon""WeaponMenu"ADMIN_MENU"Show WeaponMenu");
    
register_clcmd"say /weapons""WeaponMenu"ADMIN_MENU"Show WeaponMenu");
    
register_concmd"weapon_menu""WeaponMenu"ADMIN_MENU"Show WeaponMenu");
 }
 
 public 
WeaponMenu(id)
 {
    new 
menu menu_create("\yAdmin Weapon Menu:""menu_handler");
    
menu_additem(menu"Primary Weapons""1"0);
    
menu_additem(menu"Secondary Weapons""2"0);
    
menu_additem(menu"Grenades""3"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
 }
 public 
menu_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], iName[64];
    new 
accesscallback;
 
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
 
PrimaryMenu(id);
        }
        case 
2:
        {
 
SecondaryMenu(id);
        }
        case 
3
        {
 
GrenadeMenu(id);
        }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 }
 
 public 
PrimaryMenu(id){ 
    new 
menu menu_create("\yPrimary Weapons:""submenu_handler")
    
menu_additem(menu"M4A1""1"0);
    
menu_additem(menu"AK-47""2"0);
    
menu_additem(menu"AUG""3"0);
    
menu_additem(menu"KRIEG""4"0);
    
menu_additem(menu"GALIL""5"0);
    
menu_additem(menu"FAMAS""6"0);
    
menu_additem(menu"RAMBO""7"0);
    
menu_additem(menu"MP5-NAVY""8"0);
    
menu_additem(menu"AUTO SHOTGUN""9"0);
    
menu_additem(menu"PUMP SHOTGUN""10"0);
    
menu_additem(menu"P90""11"0);
    
menu_additem(menu"SG550""12"0);
    
menu_additem(menu"G3SG1""13"0);
    
menu_additem(menu"AWP""14"0);
    
menu_additem(menu"SCOUT""15"0);
    
menu_additem(menu"UMP45""16"0);
    
menu_additem(menu"MAC-10""17"0);
    
menu_additem(menu"TMP""18"0);
    
menu_additem(menu"\rALL WEAPONS""19"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
 }
 public 
submenu_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        if( 
is_user_connected(id) )
            
WeaponMenu(id);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
 
fm_give_item(id"weapon_m4a1");
        }
        case 
2:
        {
 
fm_give_item(id"weapon_ak47");
        }
 case 
3:
        {
 
fm_give_item(id"weapon_aug");
        }
 case 
4:
        {
 
fm_give_item(id"weapon_sg552");
        }
 case 
5:
        {
 
fm_give_item(id"weapon_galil");
        }
 case 
6:
        {
 
fm_give_item(id"weapon_famas");
        }
 case 
7:
        {
 
fm_give_item(id"weapon_m249");
        }
 case 
8:
        {
 
fm_give_item(id"weapon_mp5navy");
        }
 case 
9:
        {
 
fm_give_item(id"weapon_xm1014");
        }
 case 
10:
        {
 
fm_give_item(id"weapon_m3");
        }
 case 
11:
        {
 
fm_give_item(id"weapon_p90");
        }
 case 
12:
        {
 
fm_give_item(id"weapon_sg550");
        }
 case 
13:
        {
 
fm_give_item(id"weapon_g3sg1");
        }
 case 
14:
        {
 
fm_give_item(id"weapon_awp");
        }
 case 
15:
        {
 
fm_give_item(id"weapon_scout");
        }
 case 
16:
        {
 
fm_give_item(id"weapon_ump45");
        }
 case 
17:
        {
 
fm_give_item(id"weapon_mac10");
        }
 case 
18:
        {
 
fm_give_item(id"weapon_tmp");
        }
 case 
19:
        {
 
fm_give_item(id"weapon_m4a1");
 
fm_give_item(id"weapon_ak47");
 
fm_give_item(id"weapon_aug");
 
fm_give_item(id"weapon_sg552");
 
fm_give_item(id"weapon_galil");
 
fm_give_item(id"weapon_famas");
 
fm_give_item(id"weapon_m249");
 
fm_give_item(id"weapon_mp5navy");
 
fm_give_item(id"weapon_xm1014");
 
fm_give_item(id"weapon_m3");
 
fm_give_item(id"weapon_sg550");
 
fm_give_item(id"weapon_g3sg1");
 
fm_give_item(id"weapon_awp");
 
fm_give_item(id"weapon_scout");
 
fm_give_item(id"weapon_tmp");
 
fm_give_item(id"weapon_ump45");
 
fm_give_item(id"weapon_mac10");
 
fm_give_item(id"weapon_p90");
        }
    }
    
menu_destroy(menu);
    
WeaponMenu(id);
    return 
PLUGIN_HANDLED;
 }
 
 public 
GrenadeMenu(id){
 new 
menu2 menu_create("\yGrenades:""submenu2_handler")
 
menu_additem(menu2"He Grenade""1"0);
 
menu_additem(menu2"Smoke Grenade""2"0);
 
menu_additem(menu2"FlashBang \d(2)""3"0);
 
menu_additem(menu2"\rAll Grenades""4"0);
 
 
menu_setprop(menu2MPROP_EXITMEXIT_ALL);
 
menu_display(idmenu20);
 }
 
 public 
submenu2_handler(idmenu2item)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu2);
        if( 
is_user_connected(id) )
            
WeaponMenu(id);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menu2itemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
 
fm_give_item(id"weapon_hegrenade");
        }
        case 
2:
        {
 
fm_give_item(id"weapon_smokegrenade");
        }
 case 
3:
        {
 
fm_give_item(id"weapon_flashbang"),
 
fm_give_item(id"weapon_flashbang");
        }
 case 
4:
        {
 
fm_give_item(id"weapon_hegrenade"),
 
fm_give_item(id"weapon_smokegrenade"),
 
fm_give_item(id"weapon_flashbang"),
 
fm_give_item(id"weapon_flashbang");
        }
    }
    
menu_destroy(menu2);
    
WeaponMenu(id);
    return 
PLUGIN_HANDLED;
 }
 
 public 
SecondaryMenu(id){ 
    new 
menu3 menu_create("\yPrimary Weapons:""submenu3_handler")
    
menu_additem(menu3"DEAGLE""1"0);
    
menu_additem(menu3"USP""2"0);
    
menu_additem(menu3"GLOCK18""3"0);
    
menu_additem(menu3"COMPACT""4"0);
    
menu_additem(menu3"DUAL ELITES""5"0);
    
menu_additem(menu3"FIVESEVEN""6"0);
    
menu_additem(menu3"\r ALL PISTOLS""7"0);
    
menu_setprop(menu3MPROP_EXITMEXIT_ALL);
    
menu_display(idmenu30);
 }
 public 
submenu3_handler(idmenu3item)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu3);
        if( 
is_user_connected(id) )
            
WeaponMenu(id);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menu3itemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
 
fm_give_item(id"weapon_deagle");
        }
        case 
2:
        {
 
fm_give_item(id"weapon_usp");
        }
 case 
3:
        {
 
fm_give_item(id"weapon_glock18");
        }
 case 
4:
        {
 
fm_give_item(id"weapon_p228");
        }
 case 
5:
        {
 
fm_give_item(id"weapon_elite");
        }
 case 
6:
        {
 
fm_give_item(id"weapon_fiveseven");
        }
 case 
7:
        {
 
fm_give_item(id"weapon_deagle"),
 
fm_give_item(id"weapon_usp"),
 
fm_give_item(id"weapon_glock18"),
 
fm_give_item(id"weapon_p228"),
 
fm_give_item(id"weapon_elite"),
 
fm_give_item(id"weapon_fiveseven");
        }
    }
    
menu_destroy(menu3);
    
WeaponMenu(id);
    return 
PLUGIN_HANDLED;
 } 
__________________

Last edited by crazyeffect; 04-28-2009 at 12:13.
crazyeffect is offline
Send a message via MSN to crazyeffect
gevo
Senior Member
Join Date: Jun 2007
Old 04-27-2009 , 10:50   Re: How to make this admin only...
Reply With Quote #2

Not sure if this is what you need, I've never used this myself but it should work.

http://forums.alliedmods.net/showthread.php?t=55187
gevo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2009 , 10:55   Re: How to make this admin only...
Reply With Quote #3

You need to use cmd_access() or using directly get_user_flags() in WeaponMenu(). There are a lot of examples on this forum.
Arkshine is offline
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 04-27-2009 , 11:17   Re: How to make this admin only...
Reply With Quote #4

This?

PHP Code:
 public WeaponMenu(id)
 {
    
get_user_flags(idADMIN_MENU);
    new 
menu menu_create("\yAdmin Weapon Menu:""menu_handler");
    
menu_additem(menu"Primary Weapons""1"0);
    
menu_additem(menu"Secondary Weapons""2"0);
    
menu_additem(menu"Grenades""3"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
 } 
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 04-27-2009 , 11:58   Re: How to make this admin only...
Reply With Quote #5

PHP Code:
if(get_user_flags(id) & ADMIN_MENU)
    
//User has the flag. 
SnoW is offline
Send a message via MSN to SnoW
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 04-27-2009 , 12:43   Re: How to make this admin only...
Reply With Quote #6



Thanks

Next problem... Well... Not a problem, but it gives an error in my log file:

PHP Code:
 public WeaponMenu(id)
 {
    if(
get_user_flags(id) & ADMIN_MENU){
    new 
menu menu_create("\yAdmin Weapon Menu:""menu_handler");
    
menu_additem(menu"Primary Weapons""1"0);
    
menu_additem(menu"Secondary Weapons""2"0);
    
menu_additem(menu"Grenades""3"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
   }
   else  
// Line 30
   
{
   
client_print(idprint_chat"[`SD & C.E.] You'r not allowed to use this menu! Only admins can!"),
   
client_print(idprint_chat"[`SD & C.E.] Buy admin to get acces to this menu! [$10/Month]");
   }
 } 
Quote:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team
Warning: Loose indentation on line 30
Header size: 692 bytes
Code size: 9128 bytes
Data size: 6232 bytes
Stack/heap size: 16384 bytes; estimated max. usage=525 cells (2100 bytes)
Total requirements: 32436 bytes
1 Warning.
Done.
__________________

Last edited by crazyeffect; 04-27-2009 at 12:54.
crazyeffect is offline
Send a message via MSN to crazyeffect
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-27-2009 , 13:03   Re: How to make this admin only...
Reply With Quote #7

the indentation is screwed... have a look in the tutorials at a tutorial named "good programing habbits"

PHP Code:
public WeaponMenu(id)
{
     if(
get_user_flags(id) & ADMIN_MENU)
     {
           new 
menu menu_create("\yAdmin Weapon Menu:""menu_handler");
           
menu_additem(menu"Primary Weapons""1"0);
           
menu_additem(menu"Secondary Weapons""2"0);
           
menu_additem(menu"Grenades""3"0);
           
menu_setprop(menuMPROP_EXITMEXIT_ALL);
           
menu_display(idmenu0);
     }
     else
     {
           
client_print(idprint_chat"[`SD & C.E.] You'r not allowed to use this menu! Only admins can!"),
           
client_print(idprint_chat"[`SD & C.E.] Buy admin to get acces to this menu! [$10/Month]");
     }

As you can see I only aligned the code, didn't modify anything
__________________
Hunter-Digital is offline
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 04-27-2009 , 13:06   Re: How to make this admin only...
Reply With Quote #8

Thought something with that, but i took 3 spaces in front of it

Sorry
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-27-2009 , 18:55   Re: How to make this admin only...
Reply With Quote #9

Quote:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team
Warning: Loose indentation on line 30
Header size: 692 bytes
Code size: 9128 bytes
Data size: 6232 bytes
Stack/heap size: 16384 bytes; estimated max. usage=525 cells (2100 bytes)
Total requirements: 32436 bytes
1 Warning.
Done.
It's not an "error" it's just a warning, meaning it will run with a warning (Loose indentations doesn't affect the plugin performance). Hence the "Done."
__________________
fysiks is offline
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 04-28-2009 , 12:13   Re: How to make this admin only...
Reply With Quote #10

Yeah, but its still gives errors in your log file

I like it to be empty
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
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 14:33.


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