Skip to content

Commit 4175592

Browse files
coopryansolcloud
authored andcommitted
count grenades in buy menu to hide items when in limit
1 parent 503dcdf commit 4175592

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

cli/server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
$settings = new ServerSetting($playersMax); // must be first for correctly setting the global tickRate (Util::$TICK_RATE)
2020

2121
$logger = new ConsoleLogger();
22-
$logger->info("Preparing game for launch...");
22+
$logger->info("Preparing game for launch, please wait...");
2323

2424
$game = ($debug ? GameFactory::createDebug() : GameFactory::createDefaultCompetitive());
2525
$game->loadMap(new Maps\DefaultMap());

www/assets/js/hud/BuyMenu.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class BuyMenu {
3535
} else if (playerData.armorType === Enum.ArmorType.BODY_AND_HEAD) {
3636
kevlarHeadPrice = 650
3737
}
38+
const grenadeCount = Enum.GrenadeSlots.reduce((sum, slot) => sum += playerData.slots[slot] ? playerData.slots[slot]['pcs'] || 1 : 0, 0)
3839

3940
this.#element.innerHTML = `
4041
<p class="title">${teamName} Buy Store. Your money balance $ <strong>${money}</strong></p>
@@ -51,8 +52,11 @@ export class BuyMenu {
5152
: ``
5253
}
5354
<h3>Grenades</h3>
54-
<div class="menu-grenades">
55-
<p${money < 200 ? ' class="disabled"' : ''}><a data-buy-menu-item-id="${Enum.BuyMenuItem.GRENADE_FLASH}" class="hud-action action-buy">Flash for ${this.#formatPrice(200)}</a></p>
55+
<div class="menu-grenades${grenadeCount >= 4 ? ' hidden' : ''}">
56+
${playerData.slots[Enum.InventorySlot.SLOT_GRENADE_FLASH] === undefined || playerData.slots[Enum.InventorySlot.SLOT_GRENADE_FLASH]['pcs'] < 2
57+
? `<p${money < 200 ? ' class="disabled"' : ''}><a data-buy-menu-item-id="${Enum.BuyMenuItem.GRENADE_FLASH}" class="hud-action action-buy">Flash for ${this.#formatPrice(200)}</a></p>`
58+
: ``
59+
}
5660
${playerData.slots[Enum.InventorySlot.SLOT_GRENADE_SMOKE] === undefined
5761
? `<p${money < 300 ? ' class="disabled"' : ''}><a data-buy-menu-item-id="${Enum.BuyMenuItem.GRENADE_SMOKE}" class="hud-action action-buy">Smoke for ${this.#formatPrice(300)}</a></p>`
5862
: ``

0 commit comments

Comments
 (0)