Senior Member
|
05-10-2013
, 17:58
Menu doesent shows up.
|
#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 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; }
public Menu_Handler(id, menu, item) { if(item == MENU_EXIT) { menu_destroy(menu); return PLUGIN_HANDLED; } new data[ 6 ], iName[ 64 ], access, callback; menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
new key = str_to_num( data ); 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 i; i<sizeof(g_Primary_Weapons); i++) {
formatex(ItemName, charsmax(ItemName), "%s", g_Primary_Weapons[ i ]); menu_additem(menu, ItemName); }
menu_setprop(menu, MPROP_NUMBER_COLOR, "\y"); menu_display(id, menu, 0); return PLUGIN_HANDLED; }
public Primary_Weapons_Menu_Handler(id, menu, item) { if(item == MENU_EXIT) { menu_destroy(menu); return PLUGIN_HANDLED; } new data[ 6 ], iName[ 64 ], access, callback; menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
new key = str_to_num( data ); switch(key) { case 1:{ drop_weapons(id, 1); fm_give_item(id, "weapon_ak47"); PRIMARY_WEAPON_BIT[id] = 1; show_Secondary_Weapons_Menu(id); } case 2:{ drop_weapons(id, 1); fm_give_item(id, "weapon_m4a1"); PRIMARY_WEAPON_BIT[id] = 2; show_Secondary_Weapons_Menu(id); } case 3:{ drop_weapons(id, 1); 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 i; i<sizeof(g_Secondary_Weapons); i++) {
formatex(ItemName, charsmax(ItemName), "%s", g_Secondary_Weapons[ i ]); menu_additem(menu, ItemName); }
menu_setprop(menu, MPROP_NUMBER_COLOR, "\y"); menu_display(id, menu, 0); return PLUGIN_HANDLED; }
public Secondary_Weapons_Menu_Handler(id, menu, item) { if(item == MENU_EXIT) { menu_destroy(menu); return PLUGIN_HANDLED; } new data[ 6 ], iName[ 64 ], access, callback; menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
new key = str_to_num( data ); switch(key) { case 1:{ drop_weapons(id, 2); fm_give_item(id, "weapon_deagle"); SECONDARY_WEAPON_BIT[id] = 1; show_Grenade_Weapons_Menu(id); } case 2:{ drop_weapons(id, 2); fm_give_item(id, "weapon_usp"); SECONDARY_WEAPON_BIT[id] = 2; show_Grenade_Weapons_Menu(id); } case 3:{ drop_weapons(id, 2); 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 i; i<sizeof(g_Grenades); i++) {
formatex(ItemName, charsmax(ItemName), "%s", g_Grenades[ i ]); menu_additem(menu, ItemName); }
menu_setprop(menu, MPROP_NUMBER_COLOR, "\y"); menu_display(id, menu, 0); return PLUGIN_HANDLED; }
public Grenade_Weapons_Menu_Handler(id, menu, item) { if(item == MENU_EXIT) { menu_destroy(menu); return PLUGIN_HANDLED; }
new data[ 6 ], iName[ 64 ], access, callback; menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
new key = str_to_num( data ); 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(id, dropwhat) { static weapons[32], num, i, weaponid; num = 0; // reset passed weapons count (bugfix) get_user_weapons(id, weapons, num); for (i = 0; i < num; i++) { // Prevent re-indexing the array weaponid = weapons[i]; if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))) { static wname[32]; get_weaponname(weaponid, wname, charsmax(wname)); engclient_cmd(id, "drop", wname);
} } }
stock fm_give_item(id, const item[]) { static ent; ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item)); if (!pev_valid(ent)) return; static Float:originF[3]; pev(id, pev_origin, originF); set_pev(ent, pev_origin, originF); set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN); dllfunc(DLLFunc_Spawn, ent); static save; save = pev(ent, pev_solid); dllfunc(DLLFunc_Touch, ent, id); if (pev(ent, pev_solid) != save) return; engfunc(EngFunc_RemoveEntity, ent); }
Last edited by Menethil; 05-10-2013 at 17:59.
|
|