RemovePlayerItemEx: Reduce ammo supply for grenades and c4

This commit is contained in:
s1lentq 2023-04-27 01:01:46 +07:00
parent e090a52846
commit 4b4cd88feb

View File

@ -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()]--;
}
}
}