Plugin requested here -
https://forums.alliedmods.net/showthread.php?t=241336
Hey all! Again, I've wondering about this for hours, and no solution appeared in my head. I couldn't get that strange problem and what is it cause by, so I hope you will know. Here what's the matter. In this code, everything is OK but only for the first round. The strange is, that in other rounds the menu still appears, but no functions from it. And I think - if the handler is wrong, it should not work event the first time. But it works for the first round - and then, nothing. Here is the code, I think it could be cause by the loop trough players in the new round event. Any ideas?
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "Weapons Menu"
#define VERSION "1.0"
#define AUTHOR "Flicker"
new iMaxPlayers
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
iMaxPlayers = get_maxplayers()
register_event("HLTV", "NewRound", "a", "1=0", "2=0")
}
enum _:Data
{
_name[32],
_csw[32],
_wname[32],
_ammo[32]
}
new const Weapons[][Data]=
{
{""},
{"M4A1", CSW_M4A1, "weapon_m4a1", 90},
{"AK47", CSW_AK47, "weapon_ak47", 90}
}
public NewRound()
{
new Item[64]
for(new id = 1; id <=iMaxPlayers; id++)
{
new menu = menu_create("Free VIP Guns", "MenuHandler")
for(new i = 1; i < sizeof Weapons; i++)
{
formatex(Item, charsmax(Item), "Get %s + Deagle", Weapons[i][_name])
menu_additem(menu, Item, "", 0)
}
menu_display(id, menu, 0)
}
}
public MenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(id)
return
}
if(!is_user_alive(id))
{
client_print(id, print_chat, "You should be alive to get weapons.")
return
}
new key = item + 1
strip_user_weapons(id)
give_item(id, "weapon_knife")
give_item(id, Weapons[key][_wname])
cs_set_user_bpammo(id, Weapons[key][_csw], Weapons[key][_ammo])
give_item(id, "weapon_deagle")
cs_set_user_bpammo(id, CSW_DEAGLE, 35)
}
Whatever I choose - wokrs first round. And then, whatever I choose - nothing happens, like in the next round the handler is excluded somehow, don't know...
__________________