From 6af55160051323a5e89c20cd7f349eb637906896 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sun, 21 May 2006 22:02:22 +0000 Subject: [PATCH] added request at26380 (KWo) --- plugins/cstrike/restmenu.sma | 78 +++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/plugins/cstrike/restmenu.sma b/plugins/cstrike/restmenu.sma index 54d89eb2..23546758 100755 --- a/plugins/cstrike/restmenu.sma +++ b/plugins/cstrike/restmenu.sma @@ -45,6 +45,8 @@ new g_Modified new g_blockPos[112] new g_saveFile[64] new g_Restricted[] = "* This item is restricted *" +new g_szWeapRestr[27] = "0000000000000000000000000" +new g_szEquipAmmoRestr[10] = "000000000" new g_menusNames[7][] = { @@ -473,12 +475,12 @@ public cmdRest(id, level, cid) { setc(g_blockPos, 112, 0) // Clear current settings new arg1[64] - + if (read_argv(2, arg1, 63)) { new configsdir[32] get_configsdir(configsdir, 31) - + format(arg1, 63, "%s/%s", configsdir, arg1) } @@ -510,15 +512,15 @@ displayMenu(id, pos) { if (pos < 0) return - + new menubody[512], start = pos * 7 - + if (start >= MAXMENUPOS) start = pos = g_Position[id] = 0 - + new len = format(menubody, 511, "\y%L\R%d/5^n^n\w", id, "REST_WEAP", pos + 1) new end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0 - + if (end > MAXMENUPOS) end = MAXMENUPOS @@ -527,9 +529,9 @@ displayMenu(id, pos) keys |= (1<= 24) && (a < 31)) + { + sz[0] = g_szEquipAmmoRestr[a - 24] + g_szEquipAmmoRestr[a - 24] = (sz[0] == '0') ? '1' : '0' // equipments + } + else if (a == 31) + { + sz[0] = g_szWeapRestr[25] + g_szWeapRestr[25] = (sz[0] == '0') ? '1' : '0' // shield + } + else if ((a > 31) && (a < 34)) + { + sz[0] = g_szEquipAmmoRestr[a - 25] + g_szEquipAmmoRestr[a - 25] = (sz[0] == '0') ? '1' : '0' // primary and secondary ammo + } + set_cvar_string("amx_restrweapons", g_szWeapRestr) + set_cvar_string("amx_restrequipammo", g_szEquipAmmoRestr) } } - + return PLUGIN_HANDLED } @@ -640,12 +668,12 @@ saveSettings(filename[]) { if (file_exists(filename)) delete_file(filename) - + if (!write_file(filename, "; Generated by Restrict Weapons Plugin. Do not modify!^n; value name")) return 0 - + new text[64] - + for (new a = 0; a < MAXMENUPOS; ++a) { if (positionBlocked(a)) @@ -654,7 +682,7 @@ saveSettings(filename[]) write_file(filename, text) } } - + return 1 } @@ -662,10 +690,13 @@ loadSettings(filename[]) { if (!file_exists(filename)) return 0 - + new text[16] new a, pos = 0 - + + format(g_szEquipAmmoRestr, 9, "000000000") + format(g_szWeapRestr, 26, "00000000000000000000000000") + while (read_file(filename, pos++, text, 15, a)) { if (text[0] == ';' || !a) @@ -674,9 +705,17 @@ loadSettings(filename[]) parse(text, text, 15) if ((a = findAliasId(text)) != -1) + { setWeapon(a, 1) + if (a < 24) g_szWeapRestr[a + 1] = '1' // primary and secondary weapons + else if ((a >= 24) && (a < 31)) g_szEquipAmmoRestr[a - 24] = '1' // equipments + else if (a == 31) g_szWeapRestr[25] = '1' // shield + else if ((a > 31) && (a < 34)) g_szEquipAmmoRestr[a - 25] = '1' // primary and secondary ammo + } } - + set_cvar_string("amx_restrweapons", g_szWeapRestr) + set_cvar_string("amx_restrequipammo", g_szEquipAmmoRestr) + return 1 } @@ -787,6 +826,9 @@ public plugin_init() register_menucmd(-34, 511, "menuItem") register_concmd("amx_restrict", "cmdRest", ADMIN_CFG, "- displays help for weapons restriction") + register_cvar("amx_restrweapons", "00000000000000000000000000") + register_cvar("amx_restrequipammo", "000000000") + new configsDir[64]; get_configsdir(configsDir, 63); #if defined MAPSETTINGS