Raised This Month: $51 Target: $400
 12% 

Menu doesent shows up.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Menethil
Senior Member
Join Date: Aug 2011
Old 05-10-2013 , 17:58   Menu doesent shows up.
Reply With Quote #1

I Have a dilema.

I've tryed to make this weapons menu but at some point something went wrong.

Once I started adding things, menues arent showing when choosing from General menu.

It's shows only one time at spawn and that's it. If I select primary/secondary etc, nothing happens, so I tryed to remake it from 0. Same thing, I face this problem, maybe someone spot it better, any idea?
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>


#define fm_get_user_team(%1)    get_pdata_int(%1,114)

new PRIMARY_WEAPON_BIT[33];
new 
SECONDARY_WEAPON_BIT[33];
new 
GRENADE_WEAPON_BIT[33];


new 
g_Weapons_Menues[][]=
{
    
"Primary Weapons Menu",
    
"Secondary Weapons Menu",
    
"Grenades Menu",
    
"Remember Selection and Exit"
};

new 
g_Primary_Weapons[][] = 
{
    
"AK-47",
    
"M4A1",
    
"AWP"
};

new 
g_Secondary_Weapons[][] =
{
    
"Deagle",
    
"USP",
    
"Glock"
};

new 
g_Grenades[][] =
{
    
"HE Grenade",
    
"Flashbang",
    
"All Grenades"
};

const 
PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
const 
SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE);

new 
g_RememberSelection[33];


public 
plugin_init(){
    
register_plugin("[PvP] Weapons Menu""1.1""NeuTroN");
    
    
RegisterHam(Ham_Spawn"player""forward_Player_Spawned", .Post=true);
    
    
register_clcmd("say /guns""show_Weapons_Menu");
    
}

public 
client_connect(id){
    
g_RememberSelection[id] = false;
    
    
PRIMARY_WEAPON_BIT[id] = 0;
    
SECONDARY_WEAPON_BIT[id] = 0;
    
GRENADE_WEAPON_BIT[id] = 0;
}

public 
forward_Player_Spawned(id){

    if(
is_user_bot(id))
    return;
    
    if(!
is_user_alive(id))
    return;
    
    if(
fm_get_user_team(id) != 2)
    return;
    
    
    if(
g_RememberSelection[id]){
        switch(
PRIMARY_WEAPON_BIT[id]){
            case 
1:{
                
fm_give_item(id"weapon_ak47");
            }
            case 
2:{
                
fm_give_item(id"weapon_m4a1");
            }
            case 
3:{
                
fm_give_item(id"weapon_awp");
            }
        }
        
        switch(
SECONDARY_WEAPON_BIT[id]){
            case 
1:{
                
fm_give_item(id"weapon_deagle");
            }
            case 
2:{
                
fm_give_item(id"weapon_usp");    
            }
            case 
3:{
                
fm_give_item(id"weapon_glock");
            }
        }
        
        switch(
GRENADE_WEAPON_BIT[id]){
            case 
1:{
                
fm_give_item(id"weapon_hegrenade");
            }
            case 
2:{
                
fm_give_item(id"weapon_flashbang");
                
fm_give_item(id"weapon_flashbang");
            }
            case 
3:{
                
fm_give_item(id"weapon_hegrenade");
                
fm_give_item(id"weapon_flashbang");
                
fm_give_item(id"weapon_flashbang");
            }
        }
        
    }
    else {
        
set_task(0.2"show_Weapons_Menu"id);
    }
}

public 
show_Weapons_Menu(id){
    new 
szText[100];
    
    
formatex(szText,99"\yWeapons General Menu"); 
    new 
menu menu_create(szText"Menu_Handler");
    
    new 
ItemName[64];
    for(new 
ii<sizeof(g_Weapons_Menues); i++)
    {

        
formatex(ItemNamecharsmax(ItemName), "%s"g_Weapons_Menues[i]);
    
        
menu_additem(menuItemName);
    }

    
menu_setprop(menuMPROP_NUMBER_COLOR"\y");
    
    
menu_display(idmenu0);
    
    return 
PLUGIN_HANDLED;
}

public 
Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {    
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );

    new 
key str_to_numdata );
    
    switch(
key)
    {
        case 
1:{
        
show_Primary_Weapons_Menu(id);
        }
        case 
2:{ 
        
show_Secondary_Weapons_Menu(id);
        }
        case 
3:{
        
show_Grenade_Weapons_Menu(id);
        }
        case 
4:{
        
save_selection(id);
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
show_Primary_Weapons_Menu(id){
    new 
szText[100];
    
    
formatex(szText,99"\yPrimary Weapons Menu"); 
    new 
menu menu_create(szText"Primary_Weapons_Menu_Handler"); 
    
    new 
ItemName[64];
    for(new 
ii<sizeof(g_Primary_Weapons); i++)
    {

        
formatex(ItemNamecharsmax(ItemName), "%s"g_Primary_Weapons]);
    
        
menu_additem(menuItemName);
    }

    
menu_setprop(menuMPROP_NUMBER_COLOR"\y");
    
    
menu_display(idmenu0);
    
    return 
PLUGIN_HANDLED;
}

public 
Primary_Weapons_Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {    
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );

    new 
key str_to_numdata );
    
    switch(
key)
    {
        case 
1:{
        
drop_weapons(id1);
        
fm_give_item(id"weapon_ak47");
        
PRIMARY_WEAPON_BIT[id] = 1;
        
show_Secondary_Weapons_Menu(id);
        }
        case 
2:{
        
drop_weapons(id1);
        
fm_give_item(id"weapon_m4a1");
        
PRIMARY_WEAPON_BIT[id] = 2;
        
show_Secondary_Weapons_Menu(id);
        }
        case 
3:{
        
drop_weapons(id1);
        
fm_give_item(id"weapon_awp");
        
PRIMARY_WEAPON_BIT[id] = 3;
        
show_Secondary_Weapons_Menu(id);
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
show_Secondary_Weapons_Menu(id){
    new 
szText[100];
    
    
formatex(szText,99"\ySecondary Weapons Menu"); 
    new 
menu menu_create(szText"Secondary_Weapons_Menu_Handler"); 
    
    new 
ItemName[64];
    for(new 
ii<sizeof(g_Secondary_Weapons); i++)
    {

        
formatex(ItemNamecharsmax(ItemName), "%s"g_Secondary_Weapons]);
    
        
menu_additem(menuItemName);
    }

    
menu_setprop(menuMPROP_NUMBER_COLOR"\y");
    
    
menu_display(idmenu0);
    
    return 
PLUGIN_HANDLED;
}

public 
Secondary_Weapons_Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {    
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );

    new 
key str_to_numdata );
    
    switch(
key)
    {
        case 
1:{
        
drop_weapons(id2);
        
fm_give_item(id"weapon_deagle");
        
SECONDARY_WEAPON_BIT[id] = 1;
        
show_Grenade_Weapons_Menu(id);
        }
        case 
2:{
        
drop_weapons(id2);
        
fm_give_item(id"weapon_usp");
        
SECONDARY_WEAPON_BIT[id] = 2;
        
show_Grenade_Weapons_Menu(id);
        }
        case 
3:{
        
drop_weapons(id2);
        
fm_give_item(id"weapon_glock");
        
SECONDARY_WEAPON_BIT[id] = 3;
        
show_Grenade_Weapons_Menu(id);
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
show_Grenade_Weapons_Menu(id){
    new 
szText[100];
    
    
formatex(szText,99"\yGrenade Weapons Menu"); 
    new 
menu menu_create(szText"Grenade_Weapons_Menu_Handler") ;
    
    new 
ItemName[64];
    for(new 
ii<sizeof(g_Grenades); i++)
    {

        
formatex(ItemNamecharsmax(ItemName), "%s"g_Grenades]);
    
        
menu_additem(menuItemName);
    }

    
menu_setprop(menuMPROP_NUMBER_COLOR"\y");
    
    
menu_display(idmenu0);
    
    return 
PLUGIN_HANDLED;
}

public 
Grenade_Weapons_Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {    
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );

    new 
key str_to_numdata );
    
    switch(
key)
    {
        case 
1:{
        
fm_give_item(id"weapon_hegrenade");
        
GRENADE_WEAPON_BIT[id] = 1;
        }
        case 
2:{
        
fm_give_item(id"weapon_flashbang");
        
fm_give_item(id"weapon_flashbang");
        
GRENADE_WEAPON_BIT[id] = 2;
        }
        case 
3:{
        
fm_give_item(id"weapon_hegrenade");
        
fm_give_item(id"weapon_flashbang");
        
fm_give_item(id"weapon_flashbang");
        
GRENADE_WEAPON_BIT[id] = 3;
        }

    }
    
    return 
PLUGIN_HANDLED;
}

public 
save_selection(id){
    
g_RememberSelection[id] = true;
}
                
        
stock drop_weapons(iddropwhat)
{
    static 
weapons[32], numiweaponid;
    
num 0// reset passed weapons count (bugfix)
    
get_user_weapons(idweaponsnum);
    
    for (
0numi++)
    {
        
// Prevent re-indexing the array
        
weaponid weapons[i];
        
        if ((
dropwhat == && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
        {
            static 
wname[32];
            
get_weaponname(weaponidwnamecharsmax(wname));
          
            
engclient_cmd(id"drop"wname);

        }
    }
}

stock fm_give_item(id, const item[])
{
    static 
ent;
    
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem));
    if (!
pev_valid(ent)) return;
    
    static 
Float:originF[3];
    
pev(idpev_originoriginF);
    
set_pev(entpev_originoriginF);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);
    
    static 
save;
    
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentid);
    if (
pev(entpev_solid) != save)
        return;
    
    
engfunc(EngFunc_RemoveEntityent);


Last edited by Menethil; 05-10-2013 at 17:59.
Menethil is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-10-2013 , 18:23   Re: Menu doesent shows up.
Reply With Quote #2

Code:
public show_Weapons_Menu(id){     new szText[100];         formatex(szText,99, "\yWeapons General Menu");     new menu = menu_create(szText, "Menu_Handler");         new ItemName[64];     for(new i; i<sizeof(g_Weapons_Menues); i++)     {         formatex(ItemName, charsmax(ItemName), "%s", g_Weapons_Menues[i]);             menu_additem(menu, ItemName);     }     menu_setprop(menu, MPROP_NUMBER_COLOR, "\y");         menu_display(id, menu, 0);         return PLUGIN_HANDLED; }

why do you format the menuitem names again... they are already strings also change this
Code:
new g_Weapons_Menues[][]=
to a const
Code:
new const g_Weapons_Menues[][]=

now when you add items into menu_additem

you can just directly add from the const.

Code:
public show_Weapons_Menu(id){     new szText[100];         formatex(szText,99, "\yWeapons General Menu");     new menu = menu_create(szText, "Menu_Handler");         for( new i; i < sizeof( g_Weapons_Menues ); i++)     {            menu_additem(menu, g_Weapons_Menues [ i ]);     }     menu_setprop(menu, MPROP_NUMBER_COLOR, "\y");         menu_display(id, menu, 0);         return PLUGIN_HANDLED; }

do the same for all others.

EDIT:

not sure but you should prolly change way menu shows...

show primary menu first then once selected then it opens up the secondary then after that the nades...
__________________

Last edited by Blizzard_87; 05-10-2013 at 18:28.
Blizzard_87 is offline
Menethil
Senior Member
Join Date: Aug 2011
Old 05-10-2013 , 18:34   Re: Menu doesent shows up.
Reply With Quote #3

formating the text was just to give a little color to the menu, here is a simple way w/o color, but this is not the problem.

Also the 'const' isnt a problem.

The fun fact is, it worked when I tested first time, then I added/modifyed something and now menues are not popping up, dunno why, I went letter by letter, and still can't find the problem

Edit:
Yes I did ( getting infos from dozens of plugins from alliedmodders)

Last edited by Menethil; 05-10-2013 at 18:46.
Menethil is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-10-2013 , 18:37   Re: Menu doesent shows up.
Reply With Quote #4

Quote:
Originally Posted by Menethil View Post
formating the text was just to give a little color to the menu, here is a simple way w/o color, but this is not the problem.

Also the 'const' isnt a problem.

The fun fact is, it worked when I tested first time, then I added/modifyed something and now menues are not popping up, dunno why, I went letter by letter, and still can't find the problem
so you did write this plugin originally ?
__________________
Blizzard_87 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 05-10-2013 , 20:10   Re: Menu doesent shows up.
Reply With Quote #5

The problem is that you are not detecting the items in the handler function. Either switch with which item was pressed or add data with the item for which one is pressed.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-10-2013 , 20:29   Re: Menu doesent shows up.
Reply With Quote #6

I made up a weapons menu my style that uses same weapons that you have in your menu...
Attached Files
File Type: sma Get Plugin or Get Source (Blizzard-WeapMenu.sma - 564 views - 7.4 KB)
__________________

Last edited by Blizzard_87; 05-10-2013 at 21:26.
Blizzard_87 is offline
Menethil
Senior Member
Join Date: Aug 2011
Old 05-11-2013 , 09:37   Re: Menu doesent shows up.
Reply With Quote #7

@Blizzard_87, wasnt really a request, but ty for helping.( I really apreciate, I'll use some from u)

I took a look at csdm and zombieplague mods, and I solved it in my "old" way, without declaring the itmes intro array of strings, just directly adding items with menu_additem

Last edited by Menethil; 05-11-2013 at 09:38.
Menethil is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-11-2013 , 10:07   Re: Menu doesent shows up.
Reply With Quote #8

Quote:
Originally Posted by Menethil View Post
@Blizzard_87, wasnt really a request, but ty for helping.( I really apreciate, I'll use some from u)

I took a look at csdm and zombieplague mods, and I solved it in my "old" way, without declaring the itmes intro array of strings, just directly adding items with menu_additem
no worries
__________________
Blizzard_87 is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 08-17-2014 , 08:44   Re: Menu doesent shows up.
Reply With Quote #9

Hey Blizzard, can you add some features to weapon menu :

- remove BuyZone, Money, Round Timer and C4
- added one He Grenade after every spawn, and +1 He Grenade after every headshot kill
- added "refill weapon on kill"
- block drop command

Thanks.
Lolz0r is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 08-17-2014 , 09:05   Re: Menu doesent shows up.
Reply With Quote #10

Why don't you search? There're a lot of plugins who have that functions
__________________
skz 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 16:48.


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