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.

This commit is contained in:
Greyscale 2009-06-21 12:43:28 -07:00
parent 2e178d2ab6
commit 209c13a3f9
2 changed files with 31 additions and 16 deletions

View File

@ -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."

View File

@ -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;
}