reworked zmarket

fixed kevlar bug
This commit is contained in:
BotoX 2016-02-12 04:16:59 +01:00
parent d88e748f0e
commit 3afde85238
10 changed files with 423 additions and 349 deletions

View File

@ -52,6 +52,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "400" "zmarketprice" "400"
"zmarketcommand" "sm_glock"
} }
"USP" "USP"
@ -79,6 +80,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "500" "zmarketprice" "500"
"zmarketcommand" "sm_usp"
} }
"P228" "P228"
@ -106,7 +108,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "600" "zmarketprice" "600"
"zmarketcommand" "sm_p228"
} }
"Deagle" "Deagle"
@ -134,7 +136,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "650" "zmarketprice" "650"
"zmarketcommand" "sm_deagle"
} }
"Elite" "Elite"
@ -162,7 +164,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "800" "zmarketprice" "800"
"zmarketcommand" "sm_elite"
} }
"Fiveseven" "Fiveseven"
@ -190,7 +192,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "750" "zmarketprice" "750"
"zmarketcommand" "sm_fiveseven"
} }
"M3" "M3"
@ -218,7 +220,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "1700" "zmarketprice" "1700"
"zmarketcommand" "sm_m3"
} }
"XM1014" "XM1014"
@ -246,7 +248,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "3000" "zmarketprice" "3000"
"zmarketcommand" "sm_xm"
} }
"Mac10" "Mac10"
@ -274,6 +276,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "1400" "zmarketprice" "1400"
"zmarketcommand" "sm_mac10"
} }
"TMP" "TMP"
@ -301,6 +304,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "1250" "zmarketprice" "1250"
"zmarketcommand" "sm_tmp"
} }
"MP5Navy" "MP5Navy"
@ -328,6 +332,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "1500" "zmarketprice" "1500"
"zmarketcommand" "sm_mp5"
} }
"UMP45" "UMP45"
@ -355,6 +360,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "1700" "zmarketprice" "1700"
"zmarketcommand" "sm_ump"
} }
"P90" "P90"
@ -382,6 +388,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "2350" "zmarketprice" "2350"
"zmarketcommand" "sm_p90"
} }
"Galil" "Galil"
@ -409,6 +416,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "2000" "zmarketprice" "2000"
"zmarketcommand" "sm_galil"
} }
"Famas" "Famas"
@ -436,6 +444,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "2250" "zmarketprice" "2250"
"zmarketcommand" "sm_famas"
} }
"AK47" "AK47"
@ -463,6 +472,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "2500" "zmarketprice" "2500"
"zmarketcommand" "sm_ak"
} }
"M4A1" "M4A1"
@ -490,6 +500,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "3100" "zmarketprice" "3100"
"zmarketcommand" "sm_m4"
} }
"SG552" "SG552"
@ -517,6 +528,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "3500" "zmarketprice" "3500"
"zmarketcommand" "sm_sg552"
} }
"AUG" "AUG"
@ -544,6 +556,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "3500" "zmarketprice" "3500"
"zmarketcommand" "sm_aug"
} }
"Scout" "Scout"
@ -571,6 +584,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "2750" "zmarketprice" "2750"
"zmarketcommand" "sm_scout"
} }
"SG550" "SG550"
@ -598,6 +612,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "4200" "zmarketprice" "4200"
"zmarketcommand" "sm_sg550"
} }
"G3SG1" "G3SG1"
@ -625,6 +640,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "5000" "zmarketprice" "5000"
"zmarketcommand" "sm_g3sg1"
} }
"AWP" "AWP"
@ -652,6 +668,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "4750" "zmarketprice" "4750"
"zmarketcommand" "sm_awp"
} }
"M249" "M249"
@ -679,6 +696,7 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "5750" "zmarketprice" "5750"
"zmarketcommand" "sm_m249"
} }
"Knife" "Knife"
@ -720,6 +738,7 @@
"zmarketprice" "300" "zmarketprice" "300"
"zmarketpurchasemax" "1" "zmarketpurchasemax" "1"
"zmarketcommand" "sm_he"
} }
"Flashbang" "Flashbang"
@ -739,6 +758,7 @@
"zmarketprice" "200" "zmarketprice" "200"
"zmarketpurchasemax" "1" "zmarketpurchasemax" "1"
"zmarketcommand" "sm_flash"
} }
"Smokegrenade" "Smokegrenade"
@ -758,6 +778,7 @@
"zmarketprice" "300" "zmarketprice" "300"
"zmarketpurchasemax" "1" "zmarketpurchasemax" "1"
"zmarketcommand" "sm_smoke"
} }
"NVGs" "NVGs"
@ -776,5 +797,25 @@
// ZMarket (module) // ZMarket (module)
"zmarketprice" "1000" "zmarketprice" "1000"
"zmarketcommand" "sm_nvg"
}
"Kevlar Vest"
{
// General
"weaponentity" "item_kevlar"
"weapontype" "All, Equipment"
"weaponslot" "5"
// Restrict (core)
"restrictdefault" "no"
"toggleable" "yes"
// ZMarket (module)
"zmarketprice" "1000"
"zmarketcommand" "sm_kevlar"
} }
} }

View File

@ -76,6 +76,11 @@
"es" "Esta funcion requiere que tu seas humano." "es" "Esta funcion requiere que tu seas humano."
} }
"Must be in buyzone"
{
"es" "This feature requires that you are in a buyzone." // TODO: Translate
}
"Increase by" "Increase by"
{ {
"es" "Aumentado en {1}" "es" "Aumentado en {1}"
@ -573,14 +578,9 @@
"es" "solo se puede llevar {1} granada(s) de este tipo." "es" "solo se puede llevar {1} granada(s) de este tipo."
} }
"Weapons zmarket auto-rebuy toggle on" "Weapons zmarket not enough money"
{ {
"es" "Auto-recompra ha sido activado, su preseleccion se obtienen automaticamente cada vez que aparezcas." "es" "You have insufficient funds." // TODO: Translate
}
"Weapons zmarket auto-rebuy toggle off"
{
"es" "Auto-recompra ha sido desactivada."
} }
"Weapons zmarket updated loadout" "Weapons zmarket updated loadout"
@ -664,9 +664,9 @@
"es" "Guardar configuracion actual" "es" "Guardar configuracion actual"
} }
"Weapons menu zmarket main view loadout" "Weapons menu zmarket main edit loadout"
{ {
"es" "Ver configuracion actual" "es" "Edit Saved Setup" // TODO: Translate
} }
"Weapons menu zmarket main rebuy" "Weapons menu zmarket main rebuy"
@ -674,11 +674,6 @@
"es" "Comprar configuracion actual" "es" "Comprar configuracion actual"
} }
"Weapons menu zmarket main auto-rebuy"
{
"es" "Auto-Recompra: {1}"
}
"Weapons menu zmarket main weapons list" "Weapons menu zmarket main weapons list"
{ {
"es" "Comprar Armas" "es" "Comprar Armas"
@ -687,6 +682,7 @@
"Weapons menu zmarket loadout title" "Weapons menu zmarket loadout title"
{ {
"es" "ZMarket\nMi configuracion actual:\nSeleccione la ranura de armas para borrar.\nNota: Recompra se refiere a estas armas." "es" "ZMarket\nMi configuracion actual:\nSeleccione la ranura de armas para borrar.\nNota: Recompra se refiere a estas armas."
//"es" "ZMarket\nMy Current Setup:\nSelect weapon slot to modify.\nNote: Rebuy refers to these weapons.\nYou will spawn with these weapons." // TODO: Translate
} }
"Weapons menu zmarket loadout primary" "Weapons menu zmarket loadout primary"
@ -699,29 +695,15 @@
"es" "Secundaria: {1}" "es" "Secundaria: {1}"
} }
"Weapons menu zmarket loadout melee" "Weapons menu zmarket loadout default"
{ {
"es" "Melee: {1}" "#format" "{1:s}"
"es" "Default ({1})" // TODO: Translate
} }
"Weapons menu zmarket loadout projectile" "Weapons menu zmarket loadout weapons title"
{ {
"es" "Projectil: {1}" "es" "ZMarket\nSelect Weapon Loadout:" // TODO: Translate
}
"Weapons menu zmarket loadout explosive"
{
"es" "Explosivo: {1}"
}
"Weapons menu zmarket loadout nvgs"
{
"es" "Vision Nocturna: {1}"
}
"Weapons menu zmarket loadout empty"
{
"es" "(Ninguno)"
} }
"Weapons menu zmarket types title" "Weapons menu zmarket types title"

View File

@ -75,6 +75,11 @@
"no" "Du må være menneske for å kunne bruke denne funksjonen." "no" "Du må være menneske for å kunne bruke denne funksjonen."
} }
"Must be in buyzone"
{
"no" "This feature requires that you are in a buyzone." // TODO: Translate
}
"Increase by" "Increase by"
{ {
"no" "Økning med {1}" "no" "Økning med {1}"
@ -572,14 +577,9 @@
"no" "Du kan bare holde {1} granat(er) av denne typen." "no" "Du kan bare holde {1} granat(er) av denne typen."
} }
"Weapons zmarket auto-rebuy toggle on" "Weapons zmarket not enough money"
{ {
"no" "Autokjøp er aktivert, dine valg vil automatisk bli kjøpt hver runde eller hver gjenoppliving." "no" "You have insufficient funds." // TODO: Translate
}
"Weapons zmarket auto-rebuy toggle off"
{
"no" "Autokjøp er deaktivert."
} }
"Weapons zmarket updated loadout" "Weapons zmarket updated loadout"
@ -663,9 +663,9 @@
"no" "Lagre gjeldende våpenvalg" "no" "Lagre gjeldende våpenvalg"
} }
"Weapons menu zmarket main view loadout" "Weapons menu zmarket main edit loadout"
{ {
"no" "Vis våpenvalg" "no" "Edit Saved Setup" // TODO: Translate
} }
"Weapons menu zmarket main rebuy" "Weapons menu zmarket main rebuy"
@ -673,11 +673,6 @@
"no" "Kjøp lagret våpenvalg" "no" "Kjøp lagret våpenvalg"
} }
"Weapons menu zmarket main auto-rebuy"
{
"no" "Autokjøp: {1}"
}
"Weapons menu zmarket main weapons list" "Weapons menu zmarket main weapons list"
{ {
"no" "Vis våpenliste" "no" "Vis våpenliste"
@ -686,6 +681,7 @@
"Weapons menu zmarket loadout title" "Weapons menu zmarket loadout title"
{ {
"no" "ZMarket\nGjeldende våpenvalg:\nFjern våpen ved å velge det." "no" "ZMarket\nGjeldende våpenvalg:\nFjern våpen ved å velge det."
//"no" "ZMarket\nMy Current Setup:\nSelect weapon slot to modify.\nNote: Rebuy refers to these weapons.\nYou will spawn with these weapons." // TODO: Translate
} }
"Weapons menu zmarket loadout primary" "Weapons menu zmarket loadout primary"
@ -698,29 +694,15 @@
"no" "sekundærvåpen: {1}" "no" "sekundærvåpen: {1}"
} }
"Weapons menu zmarket loadout melee" "Weapons menu zmarket loadout default"
{ {
"no" "Nærkamp: {1}" "#format" "{1:s}"
"no" "Default ({1})" // TODO: Translate
} }
"Weapons menu zmarket loadout projectile" "Weapons menu zmarket loadout weapons title"
{ {
"no" "Prosjektiler: {1}" "no" "ZMarket\nSelect Weapon Loadout:" // TODO: Translate
}
"Weapons menu zmarket loadout explosive"
{
"no" "Granater: {1}"
}
"Weapons menu zmarket loadout nvgs"
{
"no" "Nattsyn: {1}"
}
"Weapons menu zmarket loadout empty"
{
"no" "(Ingen)"
} }
"Weapons menu zmarket types title" "Weapons menu zmarket types title"

View File

@ -76,6 +76,11 @@
"ru" "Данная функция доступна только, когда вы человек." "ru" "Данная функция доступна только, когда вы человек."
} }
"Must be in buyzone"
{
"ru" "This feature requires that you are in a buyzone." // TODO: Translate
}
"Increase by" "Increase by"
{ {
"ru" "Увеличить на {1}" "ru" "Увеличить на {1}"
@ -573,14 +578,9 @@
"ru" "Вы можете нести только {1} гранаты данного типа." "ru" "Вы можете нести только {1} гранаты данного типа."
} }
"Weapons zmarket auto-rebuy toggle on" "Weapons zmarket not enough money"
{ {
"ru" "Авто-покупка была включена, ваша амуниция будет автоматически закупаться при каждом респавне." "ru" "You have insufficient funds." // TODO: Translate
}
"Weapons zmarket auto-rebuy toggle off"
{
"ru" "Авто-покупка была отключена."
} }
"Weapons zmarket updated loadout" "Weapons zmarket updated loadout"
@ -664,9 +664,9 @@
"ru" "Сохранить текущее оружие" "ru" "Сохранить текущее оружие"
} }
"Weapons menu zmarket main view loadout" "Weapons menu zmarket main edit loadout"
{ {
"ru" "Просмотр текущй амуниции" "ru" "Edit Saved Setup" // TODO: Translate
} }
"Weapons menu zmarket main rebuy" "Weapons menu zmarket main rebuy"
@ -674,11 +674,6 @@
"ru" "Снова купить мою амуницию" "ru" "Снова купить мою амуницию"
} }
"Weapons menu zmarket main auto-rebuy"
{
"ru" "Авто-покупка: {1}"
}
"Weapons menu zmarket main weapons list" "Weapons menu zmarket main weapons list"
{ {
"ru" "Просмотр списка оружия" "ru" "Просмотр списка оружия"
@ -687,6 +682,7 @@
"Weapons menu zmarket loadout title" "Weapons menu zmarket loadout title"
{ {
"ru" "ZMarket\nМоя текущая амуниция:\nВыберите слот для очистки.\nПримечаие: Авто-покупка использует данный список." "ru" "ZMarket\nМоя текущая амуниция:\nВыберите слот для очистки.\nПримечаие: Авто-покупка использует данный список."
//"ru" "ZMarket\nMy Current Setup:\nSelect weapon slot to modify.\nNote: Rebuy refers to these weapons.\nYou will spawn with these weapons." // TODO: Translate
} }
"Weapons menu zmarket loadout primary" "Weapons menu zmarket loadout primary"
@ -699,29 +695,15 @@
"ru" "Пистолет: {1}" "ru" "Пистолет: {1}"
} }
"Weapons menu zmarket loadout melee" "Weapons menu zmarket loadout default"
{ {
"ru" "Ближний бой: {1}" "#format" "{1:s}"
"ru" "Default ({1})" // TODO: Translate
} }
"Weapons menu zmarket loadout projectile" "Weapons menu zmarket loadout weapons title"
{ {
"ru" "Снаряды: {1}" "ru" "ZMarket\nSelect Weapon Loadout:" // TODO: Translate
}
"Weapons menu zmarket loadout explosive"
{
"ru" "Взрывчатка: {1}"
}
"Weapons menu zmarket loadout nvgs"
{
"ru" "Ночное видение: {1}"
}
"Weapons menu zmarket loadout empty"
{
"ru" "(Пусто)"
} }
"Weapons menu zmarket types title" "Weapons menu zmarket types title"

View File

@ -78,6 +78,11 @@
"en" "This feature requires that you are a human." "en" "This feature requires that you are a human."
} }
"Must be in buyzone"
{
"en" "This feature requires that you are in a buyzone."
}
"Increase by" "Increase by"
{ {
"#format" "{1:s}" "#format" "{1:s}"
@ -610,14 +615,9 @@
"en" "You may only carry {1} grenade(s) of this type." "en" "You may only carry {1} grenade(s) of this type."
} }
"Weapons zmarket auto-rebuy toggle on" "Weapons zmarket not enough money"
{ {
"en" "Auto-rebuy has been enabled, your loadout will be automatically purchased for you each time you spawn." "en" "You have insufficient funds."
}
"Weapons zmarket auto-rebuy toggle off"
{
"en" "Auto-rebuy has been disabled."
} }
"Weapons zmarket updated loadout" "Weapons zmarket updated loadout"
@ -705,9 +705,9 @@
"en" "Save Current Setup" "en" "Save Current Setup"
} }
"Weapons menu zmarket main view loadout" "Weapons menu zmarket main edit loadout"
{ {
"en" "View Saved Setup" "en" "Edit Saved Setup"
} }
"Weapons menu zmarket main rebuy" "Weapons menu zmarket main rebuy"
@ -715,12 +715,6 @@
"en" "Buy Saved Setup" "en" "Buy Saved Setup"
} }
"Weapons menu zmarket main auto-rebuy"
{
"#format" "{1:s}"
"en" "Auto-Rebuy: {1}"
}
"Weapons menu zmarket main weapons list" "Weapons menu zmarket main weapons list"
{ {
"en" "Buy Weapons" "en" "Buy Weapons"
@ -728,7 +722,7 @@
"Weapons menu zmarket loadout title" "Weapons menu zmarket loadout title"
{ {
"en" "ZMarket\nMy Current Setup:\nSelect weapon slot to clear.\nNote: Rebuy refers to these weapons." "en" "ZMarket\nMy Current Setup:\nSelect weapon slot to modify.\nNote: Rebuy refers to these weapons.\nYou will spawn with these weapons."
} }
"Weapons menu zmarket loadout primary" "Weapons menu zmarket loadout primary"
@ -743,33 +737,15 @@
"en" "Secondary: {1}" "en" "Secondary: {1}"
} }
"Weapons menu zmarket loadout melee" "Weapons menu zmarket loadout default"
{ {
"#format" "{1:s}" "#format" "{1:s}"
"en" "Melee: {1}" "en" "Default ({1})"
} }
"Weapons menu zmarket loadout projectile" "Weapons menu zmarket loadout weapons title"
{ {
"#format" "{1:s}" "en" "ZMarket\nSelect Weapon Loadout:"
"en" "Projectile: {1}"
}
"Weapons menu zmarket loadout explosive"
{
"#format" "{1:s}"
"en" "Explosive: {1}"
}
"Weapons menu zmarket loadout nvgs"
{
"#format" "{1:s}"
"en" "NVGs: {1}"
}
"Weapons menu zmarket loadout empty"
{
"en" "(None)"
} }
"Weapons menu zmarket types title" "Weapons menu zmarket types title"

View File

@ -79,6 +79,8 @@ enum CvarsList
Handle:CVAR_WEAPONS_ZMARKET_BUYZONE, Handle:CVAR_WEAPONS_ZMARKET_BUYZONE,
Handle:CVAR_WEAPONS_ZMARKET_REBUY, Handle:CVAR_WEAPONS_ZMARKET_REBUY,
Handle:CVAR_WEAPONS_ZMARKET_REBUY_AUTO, Handle:CVAR_WEAPONS_ZMARKET_REBUY_AUTO,
Handle:CVAR_WEAPONS_ZMARKET_REBUY_PRIMARY,
Handle:CVAR_WEAPONS_ZMARKET_REBUY_SECONDARY,
Handle:CVAR_HITGROUPS, Handle:CVAR_HITGROUPS,
Handle:CVAR_DAMAGE_HITGROUPS, Handle:CVAR_DAMAGE_HITGROUPS,
Handle:CVAR_DAMAGE_BLOCK_FF, Handle:CVAR_DAMAGE_BLOCK_FF,
@ -299,7 +301,9 @@ CvarsCreate()
g_hCvarsList[CVAR_WEAPONS_ZMARKET] = CreateConVar("zr_weapons_zmarket", "1", "Allow player to buy from a list of weapons in the weapons config."); g_hCvarsList[CVAR_WEAPONS_ZMARKET] = CreateConVar("zr_weapons_zmarket", "1", "Allow player to buy from a list of weapons in the weapons config.");
g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE] = CreateConVar("zr_weapons_zmarket_buyzone", "1", "Requires player to be inside a buyzone to use ZMarket. [Dependency: zr_weapons_zmarket]"); g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE] = CreateConVar("zr_weapons_zmarket_buyzone", "1", "Requires player to be inside a buyzone to use ZMarket. [Dependency: zr_weapons_zmarket]");
g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY] = CreateConVar("zr_weapons_zmarket_rebuy", "1", "Allow players to rebuy their previous weapons. [Dependency: zr_weapons_zmarket]"); g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY] = CreateConVar("zr_weapons_zmarket_rebuy", "1", "Allow players to rebuy their previous weapons. [Dependency: zr_weapons_zmarket]");
g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO] = CreateConVar("zr_weapons_zmarket_rebuy_auto", "1", "Allow players to automatically rebuy their previous weapons. [Dependency: zr_weapons_zmarket&zr_weapons_zmarket_rebuy]"); g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO] = CreateConVar("zr_weapons_zmarket_rebuy_auto", "1", "Automatically equip default or loadout weapons. [Dependency: zr_weapons_zmarket&zr_weapons_zmarket_rebuy]");
g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_PRIMARY] = CreateConVar("zr_weapons_zmarket_rebuy_primary","P90", "Default primary weapon. [Dependency: zr_weapons_zmarket&zr_weapons_zmarket_rebuy]");
g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_SECONDARY] = CreateConVar("zr_weapons_zmarket_rebuy_secondary","Elite", "Default secondary weapon. [Dependency: zr_weapons_zmarket&zr_weapons_zmarket_rebuy]");
// =========================== // ===========================

View File

@ -275,6 +275,9 @@ InfectOnClientSpawn(client)
CS_SwitchTeam(client, CS_TEAM_CT); CS_SwitchTeam(client, CS_TEAM_CT);
CS_RespawnPlayer(client); CS_RespawnPlayer(client);
} }
// Unglitch kevlar. (Reset hitbox to HITBOX_GENERIC)
SetEntData(client, 4444, 0, 4);
} }
/** /**
@ -782,6 +785,10 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
} }
} }
// Remove kevlar and helmet
SetEntProp(client, Prop_Send, "m_ArmorValue", 0, 1);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 0);
// Print message to client. // Print message to client.
TranslationPrintToChat(client, "Infect infected"); TranslationPrintToChat(client, "Infect infected");
@ -853,6 +860,9 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
SpawnProtectStart(client); SpawnProtectStart(client);
} }
// Unglitch kevlar. (Reset hitbox to HITBOX_GENERIC)
SetEntData(client, 4444, 0, 4);
// Forward event to modules. // Forward event to modules.
SEffectsOnClientHuman(client); SEffectsOnClientHuman(client);
APIOnClientHumanPost(client, respawn, protect); APIOnClientHumanPost(client, respawn, protect);

View File

@ -60,6 +60,7 @@ enum WeaponsData
WEAPONS_DATA_KNOCKBACK, WEAPONS_DATA_KNOCKBACK,
WEAPONS_DATA_ZMARKETPRICE, WEAPONS_DATA_ZMARKETPRICE,
WEAPONS_DATA_ZMARKETPURCHASEMAX, WEAPONS_DATA_ZMARKETPURCHASEMAX,
WEAPONS_DATA_ZMARKETCOMMAND,
WEAPONS_DATA_RESTRICTED, WEAPONS_DATA_RESTRICTED,
} }
@ -214,6 +215,7 @@ WeaponsLoad()
// Forward event to sub-modules // Forward event to sub-modules
RestrictLoad(); RestrictLoad();
ZMarketLoad();
} }
/** /**
@ -253,6 +255,7 @@ WeaponsCacheData()
decl String:weaponentity[CONFIG_MAX_LENGTH]; decl String:weaponentity[CONFIG_MAX_LENGTH];
decl String:weapontype[CONFIG_MAX_LENGTH]; decl String:weapontype[CONFIG_MAX_LENGTH];
decl String:ammotype[CONFIG_MAX_LENGTH]; decl String:ammotype[CONFIG_MAX_LENGTH];
decl String:zmarketcommand[CONFIG_MAX_LENGTH];
// General // General
KvGetString(kvWeapons, "weaponentity", weaponentity, sizeof(weaponentity)); KvGetString(kvWeapons, "weaponentity", weaponentity, sizeof(weaponentity));
@ -273,6 +276,7 @@ WeaponsCacheData()
// ZMarket (module) // ZMarket (module)
new zmarketprice = KvGetNum(kvWeapons, "zmarketprice", -1); new zmarketprice = KvGetNum(kvWeapons, "zmarketprice", -1);
new zmarketpurchasemax = KvGetNum(kvWeapons, "zmarketpurchasemax", 0); new zmarketpurchasemax = KvGetNum(kvWeapons, "zmarketpurchasemax", 0);
KvGetString(kvWeapons, "zmarketcommand", zmarketcommand, sizeof(zmarketcommand), "");
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, x); new Handle:arrayWeapon = GetArrayCell(arrayWeapons, x);
@ -286,10 +290,11 @@ WeaponsCacheData()
PushArrayCell(arrayWeapon, ammoprice); // Index: 7 PushArrayCell(arrayWeapon, ammoprice); // Index: 7
PushArrayCell(arrayWeapon, knockback); // Index: 8 PushArrayCell(arrayWeapon, knockback); // Index: 8
PushArrayCell(arrayWeapon, zmarketprice); // Index: 9 PushArrayCell(arrayWeapon, zmarketprice); // Index: 9
PushArrayCell(arrayWeapon, zmarketpurchasemax); // Index: 10 PushArrayCell(arrayWeapon, zmarketpurchasemax); // Index: 10
PushArrayString(arrayWeapon, zmarketcommand); // Index: 11
// Initialize other stored weapon info here. // Initialize other stored weapon info here.
PushArrayCell(arrayWeapon, restrictdefault); // Index: 11 PushArrayCell(arrayWeapon, restrictdefault); // Index: 12
} }
// We're done with this file now, so we can close it. // We're done with this file now, so we can close it.
@ -691,6 +696,22 @@ stock WeaponsGetZMarketPurchaseMax(index)
return GetArrayCell(arrayWeapon, _:WEAPONS_DATA_ZMARKETPURCHASEMAX); return GetArrayCell(arrayWeapon, _:WEAPONS_DATA_ZMARKETPURCHASEMAX);
} }
/**
* Gets the name of the command to purchase this weapon through zmarket.
* @param index The weapon index.
* @param command The string to return zmarketcommand in.
* @param maxlen The max length of the string.
* @return The max purchases of the weapon.
*/
stock WeaponsGetZMarketCommand(index, String:command[], maxlen)
{
// Get array handle of weapon at given index.
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
// Return the ZMarket price of the weapon.
GetArrayString(arrayWeapon, _:WEAPONS_DATA_ZMARKETCOMMAND, command, maxlen);
}
/** /**
* General weapon API. * General weapon API.
*/ */

View File

@ -34,6 +34,11 @@
* @endsection * @endsection
*/ */
/**
* Slots saved for auto-rebuy
*/
#define ZMARKET_REBUY_WEAPONS_SLOTS_MAX 1
/** /**
* Variable to store buyzone offset value. * Variable to store buyzone offset value.
*/ */
@ -49,11 +54,6 @@ new g_iZMarketCurType[MAXPLAYERS + 1];
*/ */
new Handle:g_hZMarketPurchaseCount[MAXPLAYERS + 1]; new Handle:g_hZMarketPurchaseCount[MAXPLAYERS + 1];
/**
* Cookie handle for auto-rebuy.
*/
new Handle:g_hZMarketAutoRebuyCookie = INVALID_HANDLE;
/** /**
* Whether weapons has been bought automatically. Used to prevent double rebuy * Whether weapons has been bought automatically. Used to prevent double rebuy
* when cookies are loaded after the player was spawned. * when cookies are loaded after the player was spawned.
@ -63,7 +63,9 @@ new bool:g_bZMarketWeaponsBought[MAXPLAYERS + 1];
/** /**
* Cookie handle array for weapon loadouts. * Cookie handle array for weapon loadouts.
*/ */
new Handle:g_hZMarketLoadoutCookie[WEAPONS_SLOTS_MAX + 1]; new Handle:g_hZMarketLoadoutCookie[ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1];
new bool:g_bZMarketCommandInitialized = false;
/** /**
* Create commands specific to ZMarket. * Create commands specific to ZMarket.
@ -72,21 +74,16 @@ ZMarketOnCommandsCreate()
{ {
// Register ZMarket command. // Register ZMarket command.
RegConsoleCmd(SAYHOOKS_KEYWORD_ZMARKET, ZMarketCommand, "Opens custom buymenu."); RegConsoleCmd(SAYHOOKS_KEYWORD_ZMARKET, ZMarketCommand, "Opens custom buymenu.");
g_bZMarketCommandInitialized = false;
} }
ZMarketOnCookiesCreate() ZMarketOnCookiesCreate()
{ {
// Create auto-rebuy cookie handle if doesn't exist.
if (g_hZMarketAutoRebuyCookie == INVALID_HANDLE)
{
g_hZMarketAutoRebuyCookie = RegClientCookie(ZMARKET_COOKIE_AUTOREBUY, "The toggle state of auto-rebuy.", CookieAccess_Protected);
}
decl String:rebuycookiename[32]; decl String:rebuycookiename[32];
decl String:rebuycookiedesc[64]; decl String:rebuycookiedesc[64];
// x = Weapon slot. // x = Weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX + 1; x++) for (new x = 0; x < ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1; x++)
{ {
// Format cookie name and description. // Format cookie name and description.
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x); Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x);
@ -100,6 +97,52 @@ ZMarketOnCookiesCreate()
} }
} }
ZMarketLoad()
{
// Do not register commands multiple times
if(g_bZMarketCommandInitialized)
return;
decl String:zmarketcommand[CONFIG_MAX_LENGTH];
decl String:weaponname[WEAPONS_MAX_LENGTH];
new size = GetArraySize(arrayWeapons);
for (new weaponindex = 0; weaponindex < size; weaponindex++)
{
WeaponsGetZMarketCommand(weaponindex, zmarketcommand, sizeof(zmarketcommand));
if(zmarketcommand[0])
{
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
RegConsoleCmd(zmarketcommand, ZMarketBuyCommand, weaponname);
}
}
g_bZMarketCommandInitialized = true;
}
public Action:ZMarketBuyCommand(client, argc)
{
decl String:command[CONFIG_MAX_LENGTH];
decl String:zmarketcommand[CONFIG_MAX_LENGTH];
decl String:weaponname[WEAPONS_MAX_LENGTH];
GetCmdArg(0, command, sizeof(command));
new size = GetArraySize(arrayWeapons);
for (new weaponindex = 0; weaponindex < size; weaponindex++)
{
WeaponsGetZMarketCommand(weaponindex, zmarketcommand, sizeof(zmarketcommand));
if(StrEqual(command, zmarketcommand))
{
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
ZMarketEquip(client, weaponname);
return Plugin_Handled;
}
}
return Plugin_Handled;
}
/** /**
* Client is joining the server. * Client is joining the server.
* *
@ -123,22 +166,10 @@ ZMarketClientInit(client)
/** /**
* Called once a client's saved cookies have been loaded from the database. * Called once a client's saved cookies have been loaded from the database.
* *
* @param client Client index. * @param client Client index.
*/ */
ZMarketOnCookiesCached(client) ZMarketOnCookiesCached(client)
{ {
// Initialize auto-rebuy data.
decl String:zmarketautorebuy[8];
GetClientCookie(client, g_hZMarketAutoRebuyCookie, zmarketautorebuy, sizeof(zmarketautorebuy));
// If the cookie is empty, then set the default value.
if (!zmarketautorebuy[0])
{
// Set cookie to false.
CookiesSetClientCookieBool(client, g_hZMarketAutoRebuyCookie, false);
return;
}
// Rebuy wapons (if auto-rebuy is enabled, and not bought already). // Rebuy wapons (if auto-rebuy is enabled, and not bought already).
if (!g_bZMarketWeaponsBought[client]) if (!g_bZMarketWeaponsBought[client])
{ {
@ -184,13 +215,6 @@ ZMarketOnClientSpawnPost(client)
*/ */
ZMarketCheckRebuy(client) ZMarketCheckRebuy(client)
{ {
// If auto-rebuy is disabled, then ensure it is also disabled on the client as well.
new bool:zmarketrebuyauto = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO]);
if (!zmarketrebuyauto)
{
CookiesSetClientCookieBool(client, g_hZMarketAutoRebuyCookie, false);
}
// If client hasn't spawned into the game yet, then stop. // If client hasn't spawned into the game yet, then stop.
if (!IsClientConnected(client) || !IsClientInGame(client) || !IsPlayerAlive(client)) if (!IsClientConnected(client) || !IsClientInGame(client) || !IsPlayerAlive(client))
{ {
@ -203,12 +227,9 @@ ZMarketCheckRebuy(client)
return; return;
} }
// If auto-rebuy is enabled, then force client to rebuy weapons. // Give default/prefered spawn weapons
if (CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie)) ZMarketRebuy(client, true);
{ g_bZMarketWeaponsBought[client] = true;
ZMarketRebuy(client, true);
g_bZMarketWeaponsBought[client] = true;
}
} }
/** /**
@ -301,29 +322,22 @@ bool:ZMarketMenuMain(client)
// Add "Get Current Loadout" option. // Add "Get Current Loadout" option.
decl String:title[MENU_LINE_TITLE_LENGTH]; decl String:title[MENU_LINE_TITLE_LENGTH];
decl String:getloadout[MENU_LINE_REG_LENGTH]; decl String:getloadout[MENU_LINE_REG_LENGTH];
decl String:viewloadout[MENU_LINE_REG_LENGTH]; decl String:editloadout[MENU_LINE_REG_LENGTH];
decl String:rebuy[MENU_LINE_REG_LENGTH]; decl String:rebuy[MENU_LINE_REG_LENGTH];
decl String:rebuyauto[MENU_LINE_REG_LENGTH];
decl String:weaponslist[MENU_LINE_REG_LENGTH]; decl String:weaponslist[MENU_LINE_REG_LENGTH];
// Get auto-rebuy setting.
decl String:rebuyautosetting[MENU_LINE_SMALL_LENGTH];
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie), rebuyautosetting, sizeof(rebuyautosetting), true, client);
// Format menu options. // Format menu options.
Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket main title"); Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket main title");
Format(getloadout, sizeof(getloadout), "%t", "Weapons menu zmarket main get loadout"); Format(getloadout, sizeof(getloadout), "%t", "Weapons menu zmarket main get loadout");
Format(viewloadout, sizeof(viewloadout), "%t", "Weapons menu zmarket main view loadout"); Format(editloadout, sizeof(editloadout), "%t", "Weapons menu zmarket main edit loadout");
Format(rebuy, sizeof(rebuy), "%t", "Weapons menu zmarket main rebuy"); Format(rebuy, sizeof(rebuy), "%t", "Weapons menu zmarket main rebuy");
Format(rebuyauto, sizeof(rebuyauto), "%t", "Weapons menu zmarket main auto-rebuy", rebuyautosetting);
Format(weaponslist, sizeof(weaponslist), "%t", "Weapons menu zmarket main weapons list"); Format(weaponslist, sizeof(weaponslist), "%t", "Weapons menu zmarket main weapons list");
// Add formatted options to menu. // Add formatted options to menu.
SetMenuTitle(menu_zmarket_main, title); SetMenuTitle(menu_zmarket_main, title);
AddMenuItem(menu_zmarket_main, "Get Loadout", getloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto)); AddMenuItem(menu_zmarket_main, "Get Loadout", getloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
AddMenuItem(menu_zmarket_main, "View Loadout", viewloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto)); AddMenuItem(menu_zmarket_main, "Edit Loadout", editloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
AddMenuItem(menu_zmarket_main, "Rebuy", rebuy, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto)); AddMenuItem(menu_zmarket_main, "Rebuy", rebuy, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
AddMenuItem(menu_zmarket_main, "Auto-Rebuy", rebuyauto, MenuGetItemDraw(zmarketrebuyauto));
AddMenuItem(menu_zmarket_main, "Weapons List", weaponslist); AddMenuItem(menu_zmarket_main, "Weapons List", weaponslist);
// Set exit back button. // Set exit back button.
@ -359,10 +373,10 @@ public ZMarketMenuMainHandle(Handle:menu_zmarket_main, MenuAction:action, client
// Resend menu. // Resend menu.
ZMarketMenuMain(client); ZMarketMenuMain(client);
} }
// View loadout. // Edit loadout.
case 1: case 1:
{ {
// Show a client their current loadout. // Send the weapon loadout edit menu.
ZMarketMenuLoadout(client); ZMarketMenuLoadout(client);
} }
// Rebuy. // Rebuy.
@ -374,17 +388,8 @@ public ZMarketMenuMainHandle(Handle:menu_zmarket_main, MenuAction:action, client
// Resend menu. // Resend menu.
ZMarketMenuMain(client); ZMarketMenuMain(client);
} }
// Auto-rebuy.
case 3:
{
// Toggle the auto-rebuy cookie.
ZMarketToggleAutoRebuy(client);
// Resend menu.
ZMarketMenuMain(client);
}
// Weapons list. // Weapons list.
case 4: case 3:
{ {
// Send the weapon types list. // Send the weapon types list.
ZMarketMenuTypes(client); ZMarketMenuTypes(client);
@ -418,60 +423,48 @@ bool:ZMarketMenuLoadout(client)
new Handle:menu_zmarket_loadout = CreateMenu(ZMarketMenuLoadoutHandle); new Handle:menu_zmarket_loadout = CreateMenu(ZMarketMenuLoadoutHandle);
// Transfer cookie values into an array. // Transfer cookie values into an array.
new String:rebuyweapons[WeaponsSlot][WEAPONS_MAX_LENGTH]; new String:rebuyweapons[ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1][WEAPONS_MAX_LENGTH];
ZMarketCookiesToArray(client, rebuyweapons, WEAPONS_SLOTS_MAX + 1, sizeof(rebuyweapons[])); ZMarketCookiesToArray(client, rebuyweapons, sizeof(rebuyweapons), sizeof(rebuyweapons[]));
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
// Get the empty translation.
decl String:empty[MENU_LINE_SMALL_LENGTH];
Format(empty, sizeof(empty), "%t", "Weapons menu zmarket loadout empty");
// x = Rebuy weapon slot. // x = Rebuy weapon slot.
for (new x = 0; x < sizeof(rebuyweapons); x++) for (new x = 0; x < sizeof(rebuyweapons); x++)
{ {
// Ignore the NVG slot, we handle this separately. // If the client doesn't have a weapon in this slot, then set the weapon to the default translation.
if (WeaponsSlot:x == Slot_NVGs)
{
continue;
}
// If the client doesn't have a weapon in this slot, then set the weapon to the empty translation.
if (!rebuyweapons[x][0]) if (!rebuyweapons[x][0])
{ {
strcopy(rebuyweapons[x], sizeof(rebuyweapons[]), empty); // Get default weapon for this slot
decl String:weaponname[WEAPONS_MAX_LENGTH];
switch(x)
{
case Slot_Primary:
{
GetConVarString(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_PRIMARY], weaponname, sizeof(weaponname));
}
case Slot_Secondary:
{
GetConVarString(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_SECONDARY], weaponname, sizeof(weaponname));
}
}
Format(rebuyweapons[x], sizeof(rebuyweapons[]), "%t", "Weapons menu zmarket loadout default", weaponname);
} }
} }
// Copy "Yes/No" to NVGs string.
decl String:nvgsbool[MENU_LINE_SMALL_LENGTH];
ConfigBoolToSetting(bool:rebuyweapons[Slot_NVGs][0], nvgsbool, sizeof(nvgsbool), true, client);
decl String:title[MENU_LINE_HUGE_LENGTH]; decl String:title[MENU_LINE_HUGE_LENGTH];
decl String:primary[MENU_LINE_REG_LENGTH]; decl String:primary[MENU_LINE_REG_LENGTH];
decl String:secondary[MENU_LINE_REG_LENGTH]; decl String:secondary[MENU_LINE_REG_LENGTH];
decl String:melee[MENU_LINE_REG_LENGTH];
decl String:projectile[MENU_LINE_REG_LENGTH];
decl String:explosive[MENU_LINE_REG_LENGTH];
decl String:nvgs[MENU_LINE_REG_LENGTH];
// Format all the lines of the menu. // Format all the lines of the menu.
Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket loadout title"); Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket loadout title");
Format(primary, sizeof(primary), "%t", "Weapons menu zmarket loadout primary", rebuyweapons[Slot_Primary]); Format(primary, sizeof(primary), "%t", "Weapons menu zmarket loadout primary", rebuyweapons[Slot_Primary]);
Format(secondary, sizeof(secondary), "%t", "Weapons menu zmarket loadout secondary", rebuyweapons[Slot_Secondary]); Format(secondary, sizeof(secondary), "%t", "Weapons menu zmarket loadout secondary", rebuyweapons[Slot_Secondary]);
Format(melee, sizeof(melee), "%t", "Weapons menu zmarket loadout melee", rebuyweapons[Slot_Melee]);
Format(projectile, sizeof(projectile), "%t", "Weapons menu zmarket loadout projectile", rebuyweapons[Slot_Projectile]);
Format(explosive, sizeof(explosive), "%t", "Weapons menu zmarket loadout explosive", rebuyweapons[Slot_Explosive]);
Format(nvgs, sizeof(nvgs), "%t", "Weapons menu zmarket loadout nvgs", nvgsbool);
// Add formatted options to menu. // Add formatted options to menu.
SetMenuTitle(menu_zmarket_loadout, title); SetMenuTitle(menu_zmarket_loadout, title);
AddMenuItem(menu_zmarket_loadout, "0", primary, MenuGetItemDraw(!StrEqual(rebuyweapons[Slot_Primary], empty))); AddMenuItem(menu_zmarket_loadout, "0", primary);
AddMenuItem(menu_zmarket_loadout, "1", secondary, MenuGetItemDraw(!StrEqual(rebuyweapons[Slot_Secondary], empty))); AddMenuItem(menu_zmarket_loadout, "1", secondary);
AddMenuItem(menu_zmarket_loadout, "2", melee, MenuGetItemDraw(!StrEqual(rebuyweapons[Slot_Melee], empty)));
AddMenuItem(menu_zmarket_loadout, "3", projectile, MenuGetItemDraw(!StrEqual(rebuyweapons[Slot_Projectile], empty)));
AddMenuItem(menu_zmarket_loadout, "4", explosive, MenuGetItemDraw(!StrEqual(rebuyweapons[Slot_Explosive], empty)));
AddMenuItem(menu_zmarket_loadout, "5", nvgs, MenuGetItemDraw(bool:rebuyweapons[Slot_NVGs][0]));
// Set exit back button. // Set exit back button.
SetMenuExitBackButton(menu_zmarket_loadout, true); SetMenuExitBackButton(menu_zmarket_loadout, true);
@ -493,11 +486,20 @@ public ZMarketMenuLoadoutHandle(Handle:menu_zmarket_loadout, MenuAction:action,
// Client selected an option. // Client selected an option.
if (action == MenuAction_Select) if (action == MenuAction_Select)
{ {
// Clear rebuy slot. // Open correct submenu for weapon type
ZMarketSetRebuyCookie(client, WeaponsSlot:slot, ""); switch(slot)
{
// Re-send menu. case 0:
ZMarketMenuLoadout(client); {
g_iZMarketCurType[client] = _:Slot_Primary;
ZMarketMenuLoadoutWeapons(client, Slot_Primary);
}
case 1:
{
g_iZMarketCurType[client] = _:Slot_Secondary;
ZMarketMenuLoadoutWeapons(client, Slot_Secondary);
}
}
} }
// Client closed the menu. // Client closed the menu.
if (action == MenuAction_Cancel) if (action == MenuAction_Cancel)
@ -515,6 +517,110 @@ public ZMarketMenuLoadoutHandle(Handle:menu_zmarket_loadout, MenuAction:action,
} }
} }
ZMarketMenuLoadoutWeapons(client, WeaponsSlot:slot)
{
// Create menu handle.
new Handle:menu_zmarket_loadout_weapons = CreateMenu(ZMarketMenuLoadoutWeaponsHandle);
// Set translation target as client.
SetGlobalTransTarget(client);
decl String:title[MENU_LINE_TITLE_LENGTH];
Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket loadout weapons title");
SetMenuTitle(menu_zmarket_loadout_weapons, title);
decl String:weaponname[WEAPONS_MAX_LENGTH];
decl String:weapondisplay[MENU_LINE_REG_LENGTH];
// Get default weapon for this slot
switch(slot)
{
case Slot_Primary:
{
GetConVarString(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_PRIMARY], weaponname, sizeof(weaponname));
}
case Slot_Secondary:
{
GetConVarString(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_SECONDARY], weaponname, sizeof(weaponname));
}
}
// First item = Server default weapon
Format(weapondisplay, sizeof(weapondisplay), "%t", "Weapons menu zmarket loadout default", weaponname);
AddMenuItem(menu_zmarket_loadout_weapons, "", weapondisplay);
new size = GetArraySize(arrayWeapons);
for (new weaponindex = 0; weaponindex < size; weaponindex++)
{
// Get weapons slot
new WeaponsSlot:wslot = WeaponsGetSlot(weaponindex);
// Does it match with the slot we want?
if(wslot != slot)
continue;
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
// Get restricted status on the weapon.
new bool:restricted = RestrictIsWeaponRestricted(weaponindex);
// If weapon is restricted then format "[]" around it.
strcopy(weapondisplay, sizeof(weapondisplay), weaponname);
if (restricted)
{
Format(weapondisplay, sizeof(weapondisplay), "[%s]", weaponname);
}
// Disable weapon if it's restricted.
AddMenuItem(menu_zmarket_loadout_weapons, weaponname, weapondisplay, MenuGetItemDraw(!restricted));
}
// Set exit back button.
SetMenuExitBackButton(menu_zmarket_loadout_weapons, true);
DisplayMenu(menu_zmarket_loadout_weapons, client, MENU_TIME_FOREVER);
}
/**
* Called when client selects a weapon in the loadout weapons menu, and handles it.
*
* @param menu_zmarket_loadout_weapons Handle of the menu being used.
* @param action The action done on the menu (see menus.inc, enum MenuAction).
* @param client The client index.
* @param slot The slot index selected (starting from 0).
*/
public ZMarketMenuLoadoutWeaponsHandle(Handle:menu_zmarket_loadout_weapons, MenuAction:action, client, slot)
{
// Client selected an option.
if (action == MenuAction_Select)
{
// Get name of selected weapon.
decl String:weapon[WEAPONS_MAX_LENGTH];
GetMenuItem(menu_zmarket_loadout_weapons, slot, weapon, sizeof(weapon));
// Update cookie with new weapon.
ZMarketSetRebuyCookie(client, WeaponsSlot:g_iZMarketCurType[client], weapon);
// Open loadout menu.
ZMarketMenuLoadout(client);
}
// Client closed the menu.
if (action == MenuAction_Cancel)
{
// Client hit "Back" button.
if (slot == MenuCancel_ExitBack)
{
ZMarketMenuLoadout(client);
}
}
// Client hit "Exit" button.
else if (action == MenuAction_End)
{
CloseHandle(menu_zmarket_loadout_weapons);
}
}
/** /**
* Sends weapon type list to client. * Sends weapon type list to client.
* *
@ -784,10 +890,14 @@ public ZMarketMenuTypeWeaponsHandle(Handle:menu_zmarket_typeweapons, MenuAction:
* *
* @param client The client index. * @param client The client index.
* @param weapon The weapon to equip. (must be in weapons config file) * @param weapon The weapon to equip. (must be in weapons config file)
* @param rebuy (Optional) If client is rebuying, ammo will be ignored. * @param rebuy (Optional) If client is rebuying, ammo and cash will be ignored.
*/ */
stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false) stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
{ {
// if zombie hasn't spawned yet we're always rebuying:
if(!InfectHasZombieSpawned())
rebuy = true;
// Get weapon index. // Get weapon index.
new weaponindex = WeaponsNameToIndex(weapon); new weaponindex = WeaponsNameToIndex(weapon);
@ -801,23 +911,24 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
// Get slot index of the weapon being purchased. // Get slot index of the weapon being purchased.
new WeaponsSlot:slot = WeaponsGetSlot(weaponindex); new WeaponsSlot:slot = WeaponsGetSlot(weaponindex);
// If client is dead or a zombie, update weapon loadout instead. // If client is dead, then stop.
if (!IsPlayerAlive(client) || InfectIsClientInfected(client)) if (!IsPlayerAlive(client))
{ {
// Update cookie with new weapon. TranslationPrintToChat(client, "Must be alive");
ZMarketSetRebuyCookie(client, slot, weapon); return false;
}
TranslationPrintToChat(client, "Weapons zmarket updated loadout"); // If client is a zombie, then stop.
if (InfectIsClientInfected(client))
{
TranslationPrintToChat(client, "Must be human");
return false; return false;
} }
new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]); new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]);
if (!rebuy && zmarketbuyzone && !WeaponsIsClientInBuyZone(client)) if (!rebuy && zmarketbuyzone && !WeaponsIsClientInBuyZone(client))
{ {
// Update cookie with new weapon. TranslationPrintToChat(client, "Must be in buyzone");
ZMarketSetRebuyCookie(client, slot, weapon);
TranslationPrintToChat(client, "Weapons zmarket updated loadout");
return false; return false;
} }
@ -884,22 +995,22 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
} }
} }
// Get client's current money. if(!rebuy)
new cash = AccountGetClientCash(client);
// If client doesn't have enough money, tell them, resend menu, and then stop.
if (cash < itemprice)
{ {
// Update cookie with new weapon. // Get client's current money.
ZMarketSetRebuyCookie(client, slot, weapon); new cash = AccountGetClientCash(client);
TranslationPrintToChat(client, "Weapons zmarket updated loadout"); // If client doesn't have enough money, tell them, resend menu, and then stop.
return false; if (cash < itemprice)
{
TranslationPrintToChat(client, "Weapons zmarket not enough money");
return false;
}
// Set client's new cash after purchase.
AccountSetClientCash(client, cash - itemprice);
} }
// Set client's new cash after purchase.
AccountSetClientCash(client, cash - itemprice);
// Get a list of the client's current weapons. // Get a list of the client's current weapons.
new weapons[WeaponsSlot]; new weapons[WeaponsSlot];
WeaponsGetClientWeapons(client, weapons); WeaponsGetClientWeapons(client, weapons);
@ -913,14 +1024,23 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
// If there is already a weapon in the slot, then force client to drop it. // If there is already a weapon in the slot, then force client to drop it.
if (weapons[slot] > -1) if (weapons[slot] > -1)
{ {
// Force client to drop the weapon. if(rebuy)
WeaponsForceClientDrop(client, weapons[slot]); {
// Kill weapon right away to decrease amount of entities on roundstart.
RemoveEdict(weapons[slot]);
}
else
{
// Force client to drop the weapon.
WeaponsForceClientDrop(client, weapons[slot]);
}
} }
} }
if (StrEqual(weaponentity, "item_kevlar")) if (StrEqual(weaponentity, "item_kevlar"))
{ {
SetEntProp(client, Prop_Send, "m_ArmorValue", 100); SetEntProp(client, Prop_Send, "m_ArmorValue", 100);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
} }
else else
{ {
@ -928,16 +1048,12 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
GivePlayerItem(client, weaponentity); GivePlayerItem(client, weaponentity);
} }
// Update cookie with new weapon.
ZMarketSetRebuyCookie(client, slot, weapon);
// Add 1 to the client's purchase count.
ZMarketSetPurchaseCount(client, weapon, 1, true);
// If client isn't rebuying the weapon, then tell them the weapon has been purchased.
if (!rebuy) if (!rebuy)
{ {
// Tell client they bought a weapon. // Add 1 to the client's purchase count.
ZMarketSetPurchaseCount(client, weapon, 1, true);
// If client isn't rebuying the weapon, then tell them the weapon has been purchased.
TranslationPrintToChat(client, "Weapons zmarket purchase", weapondisplay); TranslationPrintToChat(client, "Weapons zmarket purchase", weapondisplay);
} }
} }
@ -989,15 +1105,15 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
*/ */
bool:ZMarketGetCurrentLoadout(client) bool:ZMarketGetCurrentLoadout(client)
{ {
// If client is dead, then tell them they must be alive and stop. // If client is dead, then stop.
if (!IsPlayerAlive(client)) if (!IsPlayerAlive(client))
{ {
TranslationPrintToChat(client, "Must be alive"); TranslationPrintToChat(client, "Must be alive");
return false; return false;
} }
// If client is a zombie, then tell them they must be human and stop. // If client is a zombie, then stop.
if (!IsPlayerAlive(client)) if (InfectIsClientInfected(client))
{ {
TranslationPrintToChat(client, "Must be human"); TranslationPrintToChat(client, "Must be human");
return false; return false;
@ -1011,7 +1127,7 @@ bool:ZMarketGetCurrentLoadout(client)
decl String:weaponentity[WEAPONS_MAX_LENGTH]; decl String:weaponentity[WEAPONS_MAX_LENGTH];
// x = Weapon slot. // x = Weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++) for (new x = 0; x < ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1; x++)
{ {
// If slot is empty, then clear this slot in rebuy cache and stop. // If slot is empty, then clear this slot in rebuy cache and stop.
if (weapons[x] == -1) if (weapons[x] == -1)
@ -1031,18 +1147,6 @@ bool:ZMarketGetCurrentLoadout(client)
ZMarketSetRebuyCookie(client, WeaponsSlot:x, weaponname); ZMarketSetRebuyCookie(client, WeaponsSlot:x, weaponname);
} }
// Update nightvision ownership.
new bool:nightvision = ToolsGetClientNightVision(client);
if (!nightvision)
{
// Empty rebuy slot.
ZMarketSetRebuyCookie(client, Slot_NVGs, "");
}
else
{
ZMarketSetRebuyCookie(client, Slot_NVGs, "nvgs");
}
// Tell client their loadout has been updated. // Tell client their loadout has been updated.
TranslationPrintToChat(client, "Weapons zmarket get current loadout"); TranslationPrintToChat(client, "Weapons zmarket get current loadout");
@ -1057,7 +1161,7 @@ bool:ZMarketGetCurrentLoadout(client)
* @param maxweapons The max amount of weapons in the array. * @param maxweapons The max amount of weapons in the array.
* @param maxlen The max length of each cookie result. * @param maxlen The max length of each cookie result.
*/ */
stock ZMarketArrayToCookies(client, String:rebuyweapons[WeaponsSlot][], maxweapons, maxlen) stock ZMarketArrayToCookies(client, String:rebuyweapons[ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1][], maxweapons, maxlen)
{ {
decl String:rebuycookiename[32]; decl String:rebuycookiename[32];
new Handle:rebuycookie; new Handle:rebuycookie;
@ -1083,7 +1187,7 @@ stock ZMarketArrayToCookies(client, String:rebuyweapons[WeaponsSlot][], maxweapo
* @param maxweapons The max amount of weapons in the array. * @param maxweapons The max amount of weapons in the array.
* @param maxlen The max length of each cookie result. * @param maxlen The max length of each cookie result.
*/ */
stock ZMarketCookiesToArray(client, String:rebuyweapons[WeaponsSlot][], maxweapons, maxlen) stock ZMarketCookiesToArray(client, String:rebuyweapons[ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1][], maxweapons, maxlen)
{ {
decl String:rebuycookiename[32]; decl String:rebuycookiename[32];
new Handle:rebuycookie; new Handle:rebuycookie;
@ -1155,51 +1259,36 @@ ZMarketRebuy(client, bool:autorebuy = false)
} }
// Transfer cookie values into an array. // Transfer cookie values into an array.
new String:rebuyweapons[WeaponsSlot][WEAPONS_MAX_LENGTH]; new String:rebuyweapons[ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1][WEAPONS_MAX_LENGTH];
ZMarketCookiesToArray(client, rebuyweapons, WEAPONS_SLOTS_MAX + 1, sizeof(rebuyweapons[])); ZMarketCookiesToArray(client, rebuyweapons, sizeof(rebuyweapons), sizeof(rebuyweapons[]));
// x = Weapon slot. // x = Weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX + 1; x++) for (new x = 0; x < ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1; x++)
{ {
// If slot is empty, then stop. // If slot is empty, then use the default value.
if (!rebuyweapons[x][0]) if (!rebuyweapons[x][0])
{ {
continue; switch(x)
{
case Slot_Primary:
{
GetConVarString(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_PRIMARY], rebuyweapons[x], sizeof(rebuyweapons[]));
}
case Slot_Secondary:
{
GetConVarString(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_SECONDARY], rebuyweapons[x], sizeof(rebuyweapons[]));
}
}
} }
ZMarketEquip(client, rebuyweapons[x], true); ZMarketEquip(client, rebuyweapons[x], autorebuy);
}
}
/**
* Toggle auto-rebuy on a client.
*
* @param client The client index.
*/
ZMarketToggleAutoRebuy(client)
{
// If auto-rebuy is disabled, then stop.
new bool:zmarketrebuyauto = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO]);
if (!zmarketrebuyauto)
{
return;
} }
// Get the cookie value. if(autorebuy)
new bool:autorebuystate = CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie);
// Toggle the value.
CookiesSetClientCookieBool(client, g_hZMarketAutoRebuyCookie, !autorebuystate);
// If auto-rebuy was enabled, then tell client it has been disabled.
if (autorebuystate)
{ {
TranslationPrintToChat(client, "Weapons zmarket auto-rebuy toggle off"); // Always equip kevlar and hegrenade
} ZMarketEquip(client, "Kevlar Vest", autorebuy);
// If auto-rebuy was disabled, then tell client it has been enabled. ZMarketEquip(client, "HEGrenade", autorebuy);
else
{
TranslationPrintToChat(client, "Weapons zmarket auto-rebuy toggle on");
} }
} }

View File

@ -47,38 +47,31 @@ ZCookiesMenuMain(client)
// Make client global translations target. // Make client global translations target.
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
decl String:autorebuyenabled[MENU_LINE_SMALL_LENGTH];
decl String:zhpenabled[MENU_LINE_SMALL_LENGTH]; decl String:zhpenabled[MENU_LINE_SMALL_LENGTH];
decl String:overlayenabled[MENU_LINE_SMALL_LENGTH]; decl String:overlayenabled[MENU_LINE_SMALL_LENGTH];
// Get the current toggle state of the cookies. // Get the current toggle state of the cookies.
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie), autorebuyenabled, sizeof(autorebuyenabled), false, client);
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false, client); ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false, client);
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false, client); ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false, client);
decl String:title[MENU_LINE_TITLE_LENGTH]; decl String:title[MENU_LINE_TITLE_LENGTH];
decl String:autorebuy[MENU_LINE_REG_LENGTH];
decl String:zhp[MENU_LINE_REG_LENGTH]; decl String:zhp[MENU_LINE_REG_LENGTH];
decl String:overlay[MENU_LINE_REG_LENGTH]; decl String:overlay[MENU_LINE_REG_LENGTH];
decl String:zmarket[MENU_LINE_REG_LENGTH]; decl String:zmarket[MENU_LINE_REG_LENGTH];
// Translate each line into client's language. // Translate each line into client's language.
Format(title, sizeof(title), "%t\n ", "ZCookies Menu main title"); Format(title, sizeof(title), "%t\n ", "ZCookies Menu main title");
Format(autorebuy, sizeof(autorebuy), "%t", "ZCookies menu main auto-rebuy", autorebuyenabled);
Format(zhp, sizeof(zhp), "%t", "ZCookies menu main zhp", zhpenabled); Format(zhp, sizeof(zhp), "%t", "ZCookies menu main zhp", zhpenabled);
Format(overlay, sizeof(overlay), "%t", "ZCookies menu main overlay", overlayenabled); Format(overlay, sizeof(overlay), "%t", "ZCookies menu main overlay", overlayenabled);
Format(zmarket, sizeof(zmarket), "%t", "ZCookies zmarket loadout"); Format(zmarket, sizeof(zmarket), "%t", "ZCookies zmarket loadout");
// Get conditional values for each option. // Get conditional values for each option.
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]); // For auto-rebuy.
new bool:zmarketrebuyauto = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO]); // For auto-rebuy.
new bool:zhpcvar = GetConVarBool(g_hCvarsList[CVAR_ZHP]); // For ZHP. new bool:zhpcvar = GetConVarBool(g_hCvarsList[CVAR_ZHP]); // For ZHP.
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); // For class overlay. new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); // For class overlay.
new bool:zmarketenabled = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET]); // For ZMarket loadout. new bool:zmarketenabled = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET]); // For ZMarket loadout.
// Add items to menu. // Add items to menu.
SetMenuTitle(zcookies_menu_main, title); SetMenuTitle(zcookies_menu_main, title);
AddMenuItem(zcookies_menu_main, "autorebuy", autorebuy, MenuGetItemDraw(weapons && zmarketrebuyauto));
AddMenuItem(zcookies_menu_main, "zhp", zhp, MenuGetItemDraw(zhpcvar)); AddMenuItem(zcookies_menu_main, "zhp", zhp, MenuGetItemDraw(zhpcvar));
AddMenuItem(zcookies_menu_main, "overlay", overlay, MenuGetItemDraw(overlaytoggle)); AddMenuItem(zcookies_menu_main, "overlay", overlay, MenuGetItemDraw(overlaytoggle));
AddMenuItem(zcookies_menu_main, "zmarket", zmarket, MenuGetItemDraw(zmarketenabled)); AddMenuItem(zcookies_menu_main, "zmarket", zmarket, MenuGetItemDraw(zmarketenabled));
@ -108,19 +101,13 @@ public ZCookiesMenuMainHandle(Handle:menu, MenuAction:action, client, slot)
switch(slot) switch(slot)
{ {
// Toggled auto-rebuy
case 0:
{
// Toggle the auto-rebuy cookie.
ZMarketToggleAutoRebuy(client);
}
// Toggled ZHP. // Toggled ZHP.
case 1: case 0:
{ {
ZHPToggle(client); ZHPToggle(client);
} }
// Toggled class overlay. // Toggled class overlay.
case 2: case 1:
{ {
// If overlay toggle is disabled, then stop. // If overlay toggle is disabled, then stop.
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
@ -132,7 +119,7 @@ public ZCookiesMenuMainHandle(Handle:menu, MenuAction:action, client, slot)
} }
} }
// Opened ZMarket loadout. // Opened ZMarket loadout.
case 3: case 2:
{ {
// Show a client their current loadout. // Show a client their current loadout.
ZMarketMenuLoadout(client); ZMarketMenuLoadout(client);