From 4b4cd88feb30276e335b57b782e3766aade69546 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 27 Apr 2023 01:01:46 +0700 Subject: [PATCH] RemovePlayerItemEx: Reduce ammo supply for grenades and c4 --- regamedll/dlls/API/CSPlayer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index d40cb921..34d00693 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -226,6 +226,14 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov if (bRemoveAmmo) { pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0; + } else { + // These weapons have a unique type of ammo that is used only by them + // If a weapon is removed, its ammo is also reduced, unless the ammo can be used by another weapon + if (IsGrenadeWeapon(pItem->m_iId) || pItem->m_iId == WEAPON_C4) + { + if (pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] > 0) + pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]--; + } } }