added request at26380 (KWo)

This commit is contained in:
Borja Ferrer 2006-05-21 22:02:22 +00:00
parent 444e2caa68
commit 6af5516005

View File

@ -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<<k)
len += format(menubody[len], 511 - len, g_MenuItem[a], ++k, g_WeaponNames[a], id, positionBlocked(a) ? "ON" : "OFF")
}
len += format(menubody[len], 511 - len, "^n8. %L \y\R%s^n\w", id, "SAVE_SET", g_Modified ? "*" : "")
if (end != MAXMENUPOS)
{
format(menubody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
@ -537,7 +539,7 @@ displayMenu(id, pos)
}
else
format(menubody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menubody, -1, "Restrict Weapons")
}
@ -554,7 +556,7 @@ public actionMenu(id, key)
}
else
client_print(id, print_chat, "* %L", id, "CONF_SAV_FAIL")
displayMenu(id, g_Position[id])
}
case 8: displayMenu(id, ++g_Position[id])
@ -564,9 +566,35 @@ public actionMenu(id, key)
setWeapon(g_Position[id] * 7 + key, 2)
g_Modified = true
displayMenu(id, g_Position[id])
new a = g_Position[id] * 7 + key
new sz[1]
if (a < 24)
{
sz[0] = g_szWeapRestr[a + 1]
g_szWeapRestr[a + 1] = (sz[0] == '0') ? '1' : '0' // primary and secondary weapons
}
else if ((a >= 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