diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index c63b504b..41a7fef4 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -203,40 +203,7 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov else if (FStrEq(pszItemName, "weapon_shield")) { - if (!pPlayer->HasShield()) - return false; - - bool bIsProtectedShield = pPlayer->IsProtectedByShield(); - pPlayer->RemoveShield(); - - CBasePlayerWeapon *pWeapon = static_cast(pPlayer->m_pActiveItem); - if (pWeapon) - { - if (!pWeapon->CanHolster()) - return false; - - if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE) - { - if (pPlayer->m_rgAmmo[pWeapon->m_iPrimaryAmmoType] <= 0) - g_pGameRules->GetNextBestWeapon(pPlayer, pWeapon); - } - - if (pWeapon->m_flStartThrow != 0.0f) - pWeapon->Holster(); - - if (pPlayer->IsReloading()) - { - pWeapon->m_fInReload = FALSE; - pPlayer->m_flNextAttack = 0; - } - - if (bIsProtectedShield) - pWeapon->SecondaryAttack(); - - pWeapon->Deploy(); - } - - return true; + return RemoveShield(); } auto pItem = GetItemByName(pszItemName); @@ -293,6 +260,7 @@ EXT_FUNC CBaseEntity *CCSPlayer::GiveNamedItemEx(const char *pszName) } } else if (FStrEq(pszName, "weapon_shield")) { pPlayer->DropPrimary(); + pPlayer->DropPlayerItem("weapon_elite"); pPlayer->GiveShield(); return nullptr; } @@ -340,9 +308,45 @@ EXT_FUNC void CCSPlayer::DropPlayerItem(const char *pszItemName) BasePlayer()->DropPlayerItem(pszItemName); } -EXT_FUNC void CCSPlayer::RemoveShield() +EXT_FUNC bool CCSPlayer::RemoveShield() { - BasePlayer()->RemoveShield(); + CBasePlayer *pPlayer = BasePlayer(); + + if (!pPlayer->HasShield()) + return false; + + bool bIsProtectedShield = pPlayer->IsProtectedByShield(); + pPlayer->RemoveShield(); + + CBasePlayerWeapon *pWeapon = static_cast(pPlayer->m_pActiveItem); + if (pWeapon && pWeapon->IsWeapon()) + { + if (!pWeapon->CanHolster()) + return false; + + if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE) + { + if (pPlayer->m_rgAmmo[pWeapon->m_iPrimaryAmmoType] <= 0) + g_pGameRules->GetNextBestWeapon(pPlayer, pWeapon); + } + + if (pWeapon->m_flStartThrow != 0.0f) + pWeapon->Holster(); + + if (pPlayer->IsReloading()) + { + pWeapon->m_fInReload = FALSE; + pPlayer->m_flNextAttack = 0; + } + + if (bIsProtectedShield) + pWeapon->SecondaryAttack(); + + if (!pWeapon->Deploy()) + return false; + } + + return true; } EXT_FUNC void CCSPlayer::RemoveAllItems(bool bRemoveSuit) diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 5483907a..6525c1ca 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -58,7 +58,7 @@ public: virtual void GiveShield(bool bDeploy = true); virtual void DropShield(bool bDeploy = true); virtual void DropPlayerItem(const char *pszItemName); - virtual void RemoveShield(); + virtual bool RemoveShield(); virtual void RemoveAllItems(bool bRemoveSuit); virtual bool RemovePlayerItem(const char* pszItemName); virtual void SetPlayerModel(bool bHasC4);