fixed bug am47617
This commit is contained in:
parent
627b3f0f98
commit
4332d6c271
|
@ -47,6 +47,18 @@ new g_saveFile[64]
|
|||
new g_Restricted[] = "* This item is restricted *"
|
||||
new g_szWeapRestr[27] = "0000000000000000000000000"
|
||||
new g_szEquipAmmoRestr[10] = "000000000"
|
||||
new g_InBuyMenu[33]
|
||||
new g_RegisteredMenus[10]
|
||||
|
||||
new g_menuStrings[6][] =
|
||||
{
|
||||
"BuyPistol",
|
||||
"BuyShotgun",
|
||||
"BuySubMachineGun",
|
||||
"BuyRifle",
|
||||
"BuyMachineGun",
|
||||
"BuyItem"
|
||||
}
|
||||
|
||||
new g_menusNames[7][] =
|
||||
{
|
||||
|
@ -295,6 +307,19 @@ new g_Aliases2[MAXMENUPOS][] =
|
|||
new g_Autobuy[33][AUTOBUYLENGTH + 1]
|
||||
//new g_Rebuy[33][AUTOBUYLENGTH + 1]
|
||||
|
||||
bool:IsOurMenuID(id)
|
||||
{
|
||||
for (new i=1; i<=g_RegisteredMenus[0]; i++)
|
||||
{
|
||||
if (g_RegisteredMenus[i] == id)
|
||||
{
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
setWeapon(a, action)
|
||||
{
|
||||
new b, m = g_Keys[a][0] * 8
|
||||
|
@ -605,7 +630,30 @@ public client_command(id)
|
|||
new arg[13]
|
||||
|
||||
if (read_argv(0, arg, 12) > 11) /* Longest buy command has 11 chars so if command is longer then don't care */
|
||||
{
|
||||
return PLUGIN_CONTINUE
|
||||
}
|
||||
|
||||
if (equali(arg, "menuselect"))
|
||||
{
|
||||
new menu, newmenu
|
||||
new inMenu = player_menu_info(id, menu, newmenu)
|
||||
|
||||
if (!inMenu && g_InBuyMenu[id])
|
||||
{
|
||||
new key[12], num
|
||||
|
||||
read_argv(1, key, 11)
|
||||
num = str_to_num(key) - 1
|
||||
|
||||
return checkRest(id, g_InBuyMenu[id], num)
|
||||
} else if ((!menu || newmenu != -1)
|
||||
|| !IsOurMenuID(menu)) {
|
||||
g_InBuyMenu[id] = 0
|
||||
}
|
||||
|
||||
return PLUGIN_CONTINUE
|
||||
}
|
||||
|
||||
new a = 0
|
||||
|
||||
|
@ -799,6 +847,70 @@ public fn_autobuy(id)
|
|||
return PLUGIN_HANDLED
|
||||
}
|
||||
|
||||
public HookEvent_ShowMenu(id)
|
||||
{
|
||||
new menustring[24]
|
||||
|
||||
read_data(4, menustring, 23)
|
||||
|
||||
/* Early breakouts */
|
||||
new curidx
|
||||
if (menustring[curidx++] != '#')
|
||||
{
|
||||
g_InBuyMenu[id] = 0
|
||||
return
|
||||
}
|
||||
|
||||
/* Strip D */
|
||||
if (menustring[curidx] == 'D')
|
||||
{
|
||||
curidx++
|
||||
}
|
||||
|
||||
/* Strip AS_ */
|
||||
if (menustring[curidx] == 'A'
|
||||
&& menustring[curidx+1] == 'S'
|
||||
&& menustring[curidx+2] == '_')
|
||||
{
|
||||
curidx += 3
|
||||
}
|
||||
|
||||
/* Strip any team tags */
|
||||
if (menustring[curidx] == 'C'
|
||||
&& menustring[curidx+1] == 'T'
|
||||
&& menustring[curidx+2] == '_')
|
||||
{
|
||||
curidx += 3
|
||||
} else if (menustring[curidx] == 'T'
|
||||
&& menustring[curidx+1] == '_') {
|
||||
curidx += 2
|
||||
}
|
||||
|
||||
if (menustring[curidx] != 'B')
|
||||
{
|
||||
g_InBuyMenu[id] = 0
|
||||
return
|
||||
}
|
||||
|
||||
for (new i=0; i<6; i++)
|
||||
{
|
||||
if (equali(menustring[curidx], g_menuStrings[i]))
|
||||
{
|
||||
g_InBuyMenu[id] = i+1
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
g_InBuyMenu[id] = 0
|
||||
}
|
||||
|
||||
RegisterMenuID(const menuname[])
|
||||
{
|
||||
new id = register_menuid(menuname, 1)
|
||||
g_RegisteredMenus[++g_RegisteredMenus[0]] = id
|
||||
return id
|
||||
}
|
||||
|
||||
public plugin_init()
|
||||
{
|
||||
register_plugin("Restrict Weapons", AMXX_VERSION_STR, "AMXX Dev Team")
|
||||
|
@ -811,12 +923,12 @@ public plugin_init()
|
|||
register_clcmd("amx_restmenu", "cmdMenu", ADMIN_CFG, "- displays weapons restriction menu")
|
||||
register_menucmd(register_menuid("#Buy", 1), 511, "menuBuy")
|
||||
register_menucmd(register_menuid("Restrict Weapons"), 1023, "actionMenu")
|
||||
register_menucmd(register_menuid("BuyPistol", 1), 511, "menuPistol")
|
||||
register_menucmd(register_menuid("BuyShotgun", 1), 511, "menuShotgun")
|
||||
register_menucmd(register_menuid("BuySub", 1), 511, "menuSub")
|
||||
register_menucmd(register_menuid("BuyRifle", 1), 511, "menuRifle")
|
||||
register_menucmd(register_menuid("BuyMachine", 1), 511, "menuMachine")
|
||||
register_menucmd(register_menuid("BuyItem", 1), 511, "menuItem")
|
||||
register_menucmd(RegisterMenuID("BuyPistol"), 511, "menuPistol")
|
||||
register_menucmd(RegisterMenuID("BuyShotgun"), 511, "menuShotgun")
|
||||
register_menucmd(RegisterMenuID("BuySub"), 511, "menuSub")
|
||||
register_menucmd(RegisterMenuID("BuyRifle"), 511, "menuRifle")
|
||||
register_menucmd(RegisterMenuID("BuyMachine"), 511, "menuMachine")
|
||||
register_menucmd(RegisterMenuID("BuyItem"), 511, "menuItem")
|
||||
register_menucmd(-28, 511, "menuBuy")
|
||||
register_menucmd(-29, 511, "menuPistol")
|
||||
register_menucmd(-30, 511, "menuShotgun")
|
||||
|
@ -828,6 +940,8 @@ public plugin_init()
|
|||
|
||||
register_cvar("amx_restrweapons", "00000000000000000000000000")
|
||||
register_cvar("amx_restrequipammo", "000000000")
|
||||
|
||||
register_event("ShowMenu", "HookEvent_ShowMenu", "b")
|
||||
|
||||
new configsDir[64];
|
||||
get_configsdir(configsDir, 63);
|
||||
|
|
Loading…
Reference in New Issue
Block a user