From 7f12e999e686c206fd061a7c2c311335ea7be54d Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 23 Jan 2017 18:59:39 +0700 Subject: [PATCH] Improves native rg_remove_items_by_slot --- reapi/src/natives/natives_misc.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 50c19b1..0873dee 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -806,12 +806,23 @@ cell AMX_NATIVE_CALL rg_remove_items_by_slot(AMX *amx, cell *params) CHECK_CONNECTED(pPlayer, arg_index); pPlayer->ForEachItem(params[arg_slot], [pPlayer](CBasePlayerItem *pItem) { - pPlayer->pev->weapons &= ~(1 << pItem->m_iId); - pPlayer->RemovePlayerItem(pItem); - pItem->Kill(); + + if (pItem->IsWeapon() && pItem == pPlayer->m_pActiveItem) { + ((CBasePlayerWeapon *)pItem)->RetireWeapon(); + } + + if (pPlayer->RemovePlayerItem(pItem)) { + pPlayer->pev->weapons &= ~(1 << pItem->m_iId); + pItem->Kill(); + } + return false; }); + if (!pPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]) { + pPlayer->m_bHasPrimary = false; + } + return TRUE; }