AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What is wrong? (https://forums.alliedmods.net/showthread.php?t=195721)

pacheco 09-10-2012 18:17

What is wrong?
 
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 ! :crab:

jimaway 09-10-2012 18:48

Re: What is wrong?
 
szCommand = Key -1

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

pacheco 09-10-2012 19:05

Re: What is wrong?
 
Quote:

Originally Posted by jimaway (Post 1796264)
szCommand = Key -1

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

Thanks! But didn't work :/

fysiks 09-10-2012 19:34

Re: What is wrong?
 
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.

pacheco 09-10-2012 19:39

Re: What is wrong?
 
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

fysiks 09-10-2012 19:41

Re: What is wrong?
 
Quote:

Originally Posted by pacheco (Post 1796307)
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 (Post 1796301)
I would recommend starting over and thinking it through step by step how the functions would be called.

Or posting the Requests section.


All times are GMT -4. The time now is 08:15.

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