From 61911d94402f2af6653f9ed4f235293b1caa2dcd Mon Sep 17 00:00:00 2001 From: Vaqtincha Date: Tue, 22 Feb 2022 22:09:50 +0500 Subject: [PATCH 1/2] fix player_weaponstrip --- regamedll/dlls/player.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 9a97f2c86..860a17d39 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -6667,7 +6667,7 @@ void CBasePlayer::HandleSignals() m_signals.Signal(SIGNAL_BOMB); } } -#endif +#endif if (!CSGameRules()->m_bMapHasBombZone) OLD_CheckBombTarget(this); @@ -8401,7 +8401,12 @@ void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE { if (m_iszSpecialItem) { - pPlayer->CSPlayer()->RemovePlayerItem(STRING(m_iszSpecialItem)); + const char *weaponName = STRING(m_iszSpecialItem); + + if (GetWeaponSlot(weaponName)->slot == GRENADE_SLOT) + pPlayer->CSPlayer()->RemovePlayerItemEx(weaponName, true); + else + pPlayer->CSPlayer()->RemovePlayerItem(weaponName); } for (int slot = PRIMARY_WEAPON_SLOT; slot <= ALL_OTHER_ITEMS; slot++) @@ -8422,7 +8427,11 @@ void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE { pPlayer->ForEachItem(slot, [pPlayer](CBasePlayerItem *pItem) { - pPlayer->CSPlayer()->RemovePlayerItem(STRING(pItem->pev->classname)); + if (pItem->iItemSlot() == GRENADE_SLOT) + pPlayer->CSPlayer()->RemovePlayerItemEx(STRING(pItem->pev->classname), true); + else + pPlayer->CSPlayer()->RemovePlayerItem(STRING(pItem->pev->classname)); + return false; }); } From 08433e2c8fbe2b975be33a40deb199504a782916 Mon Sep 17 00:00:00 2001 From: Vaqtincha Date: Wed, 23 Feb 2022 01:29:03 +0500 Subject: [PATCH 2/2] safe checks --- regamedll/dlls/player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 860a17d39..db77365a7 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8402,8 +8402,9 @@ void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE if (m_iszSpecialItem) { const char *weaponName = STRING(m_iszSpecialItem); + WeaponSlotInfo *slotInfo = GetWeaponSlot(weaponName); - if (GetWeaponSlot(weaponName)->slot == GRENADE_SLOT) + if (slotInfo != nullptr && slotInfo->slot == GRENADE_SLOT) pPlayer->CSPlayer()->RemovePlayerItemEx(weaponName, true); else pPlayer->CSPlayer()->RemovePlayerItem(weaponName);