From 209c13a3f989259520170ba414820b0d6cfd49e7 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Sun, 21 Jun 2009 12:43:28 -0700 Subject: [PATCH] ZMarket now allows you to update your loadout but selecting a weapon from the list, but if you are not able to (out of buyzone, zombie, etc) then the weapon won't actually be given. --- .../translations/zombiereloaded.phrases.txt | 5 +++ src/zr/weapons/zmarket.inc | 42 ++++++++++++------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt index 691f288..e685153 100644 --- a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt @@ -532,6 +532,11 @@ "en" "Weapon @green{1} @defaulthas a purchase limit of @green{2}@default. Wait until you respawn to try again." } + "Weapons zmarket updated loadout" + { + "en" "You are not able to purchase a weapon at this time, but your loadout has been updated with this weapon." + } + "Weapons zmarket get current loadout" { "en" "Updated current loadout, use rebuy option to purchase these weapons again." diff --git a/src/zr/weapons/zmarket.inc b/src/zr/weapons/zmarket.inc index 69f715e..dd09e86 100644 --- a/src/zr/weapons/zmarket.inc +++ b/src/zr/weapons/zmarket.inc @@ -737,32 +737,39 @@ public ZMarketMenuTypeWeaponsHandle(Handle:menu_zmarket_typeweapons, MenuAction: */ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false) { - // If client is a zombie, then stop. + // Get weapon index. + new weaponindex = WeaponsNameToIndex(weapon); + + // Get slot index of the weapon being purchased. + new WeaponsSlot:slot = WeaponsGetSlot(weaponindex); + + // If weapon index is -1, then something went very wrong. + if (weaponindex == -1) + { + LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Weapons, "ZMarket Equip", "Invalid weapon (%s) selected from the ZMarket menu.", weapon); + return false; + } + + // If client is a zombie, then update weapon loadout and stop. if (InfectIsClientInfected(client)) { - TranslationPrintToChat(client, "Must be human"); + // Update cookie with new weapon. + ZMarketSetRebuyCookie(client, slot, weapon); + + TranslationPrintToChat(client, "Weapons zmarket updated loadout"); return false; } new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]); if (!rebuy && zmarketbuyzone && !ZMarketIsClientInBuyZone(client)) { - TranslationPrintToChat(client, "Weapons zmarket buyzone"); + // Update cookie with new weapon. + ZMarketSetRebuyCookie(client, slot, weapon); + + TranslationPrintToChat(client, "Weapons zmarket updated loadout"); return false; } - // Get weapon index. - new weaponindex = WeaponsNameToIndex(weapon); - - // If weapon index is -1, then something went very wrong. - if (weaponindex == -1) - { - return false; - } - - // Get slot index of the weapon being purchased. - new WeaponsSlot:slot = WeaponsGetSlot(weaponindex); - // Get the appropriate price of the item being purchased. new bool:hasweapon = WeaponsClientHasWeapon(client, weapon); new itemprice = (hasweapon && slot != Slot_Invalid && slot != Slot_Projectile) ? WeaponsGetAmmoPrice(weaponindex) : WeaponsGetZMarketPrice(weaponindex); @@ -779,7 +786,10 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false) // If client doesn't have enough money, tell them, resend menu, and then stop. if (cash < itemprice) { - TranslationPrintToChat(client, "Not enough money"); + // Update cookie with new weapon. + ZMarketSetRebuyCookie(client, slot, weapon); + + TranslationPrintToChat(client, "Weapons zmarket updated loadout"); return false; }