Raised This Month: $ Target: $400
 0% 

What is wrong?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pacheco
Senior Member
Join Date: Jul 2011
Old 09-10-2012 , 18:17   What is wrong?
Reply With Quote #1

PHP Code:
#include <amxmodx>

new szCMD[][] =
{
    
"bb_buildban"// 1
    
"bb_unbuildban"// 2
    
"bb_revive"// 3
    
"bb_guns" // 4
};

new 
szOptions[][] = 
{
    
"Ban"// 1
    
"Unban"// 2
    
"Respawn"// 3
    
"Open Guns Menu" // 4
};

new 
szCommandtempid;

public 
plugin_init()
{
    
register_plugin("[BBXP] ADMIN MENU""1.0""pacheco");

    
register_clcmd("say /menuadm""menu_admin");
    
register_clcmd("say /admin""menu_admin");
}

public 
menu_admin(id)
{
    new 
szMenu menu_create("\y[BBXP] \wMenu Administrador \d(2)" "admin_handler");

    new 
szNum[128];
    
    for(new 
0sizeof(szOptions); i++)
    {
        
num_to_str(1szNum127);
        
menu_additem(szMenuszOptions[i], szNum0);
    }
    
    
menu_display(idszMenu);
}

public 
admin_handler(id)
{
    new 
menu menu_create("\y[BBXP] \wSelect one Player:""menu_handler_go");

          
menu_setprop(menuMPROP_BACKNAME"Back");
    
menu_setprop(menuMPROP_EXITNAME"Exit");
    
menu_setprop(menuMPROP_NEXTNAME"Next");

    new 
players[32], pnum;

    new 
szName[32], szTempid[10];

    
get_players(playerspnum);

    for( new 
ii<pnumi++ )
    {
        
tempid players[i];

        
get_user_name(tempidszNamecharsmax(szName));
        
num_to_str(tempidszTempidcharsmax(szTempid));

        
menu_additem(menuszNameszTempid0);
    }
    
menu_display(idmenu0);
}

public 
menu_handler_go(idszMenuiItem
{
    if(
iItem == MENU_EXIT
        return 
PLUGIN_HANDLED
    
    new 
szData[6], szName[64];
    new 
iAccessiCallBack;
    
menu_item_getinfo(szMenuiItemiAccessszData,5szName63iCallBack);
    
    new 
Key str_to_num(szData);
    
    
szCommand Key;

    new 
szNameT[33];
    
get_user_name(tempidszNameTcharsmax(szNameT));

    
client_cmd(id"%s ^"%s^""szCMD[szCommand], szNameT);
    
client_print(0print_chat"Command: %s"szCMD[szCommand]);
    
    
menu_destroy(szMenu);
    return 
PLUGIN_HANDLED;

When i select the first option in first menu, the command is: bb_unbuildban but i want bb_buildban! What is wrong in the code? Thanks !
__________________




Last edited by pacheco; 09-10-2012 at 19:41.
pacheco is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-10-2012 , 18:48   Re: What is wrong?
Reply With Quote #2

szCommand = Key -1

or just remove + 1 from
num_to_str(i + 1, szNum, 127)

Last edited by jimaway; 09-10-2012 at 18:49.
jimaway is offline
pacheco
Senior Member
Join Date: Jul 2011
Old 09-10-2012 , 19:05   Re: What is wrong?
Reply With Quote #3

Quote:
Originally Posted by jimaway View Post
szCommand = Key -1

or just remove + 1 from
num_to_str(i + 1, szNum, 127)
Thanks! But didn't work :/
__________________




Last edited by pacheco; 09-10-2012 at 19:32.
pacheco is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-10-2012 , 19:34   Re: What is wrong?
Reply With Quote #4

You have a menu handler that creates another menu . . . that makes no sense. I would recommend starting over and thinking it through step by step how the functions would be called.

Also, the "sz" prefix is for strings (zero-terminated) not for integers.
__________________

Last edited by fysiks; 09-10-2012 at 19:41. Reason: typo
fysiks is offline
pacheco
Senior Member
Join Date: Jul 2011
Old 09-10-2012 , 19:39   Re: What is wrong?
Reply With Quote #5

Quote:
You have a menu handler that creates another menu . . . that makes no sense. I would recommend staring over and thinking it through step by step how the functions would be called.
Yep.. Because i have to select the option and one player..
I've changed one thing,
Code:
 szCommand = menu_item_getinfo(szMenu, iItem, iAccess, szData,5, szName, 63, iCallBack);
but still don't work.. Do you know other method to do this? Thanks
__________________



pacheco is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-10-2012 , 19:41   Re: What is wrong?
Reply With Quote #6

Quote:
Originally Posted by pacheco View Post
Yep.. Because i have to select the option and one player..
I've changed one thing,
Code:
 szCommand = menu_item_getinfo(szMenu, iItem, iAccess, szData,5, szName, 63, iCallBack);
but still don't work.. Do you know other method to do this? Thanks
Wow, you really have no idea what you are doing . . .

Quote:
Originally Posted by fysiks View Post
I would recommend starting over and thinking it through step by step how the functions would be called.
Or posting the Requests section.
__________________

Last edited by fysiks; 09-10-2012 at 19:42.
fysiks 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 08:15.


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