View Single Post
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