From 6eaf6ffeb599887840b99ca4d4244eb48f9e700d Mon Sep 17 00:00:00 2001 From: Javekson Date: Tue, 3 Oct 2023 18:44:29 +0400 Subject: [PATCH 1/3] Changed return types for DropShield and DropPlayerItem to CBaseEntity to retrieve created entity index --- reapi/include/cssdk/dlls/API/CSPlayer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reapi/include/cssdk/dlls/API/CSPlayer.h b/reapi/include/cssdk/dlls/API/CSPlayer.h index 3f63d5c3..b12aa230 100644 --- a/reapi/include/cssdk/dlls/API/CSPlayer.h +++ b/reapi/include/cssdk/dlls/API/CSPlayer.h @@ -64,8 +64,8 @@ class CCSPlayer: public CCSMonster virtual CBaseEntity *GiveNamedItemEx(const char *pszName) = 0; virtual void GiveDefaultItems() = 0; virtual void GiveShield(bool bDeploy = true) = 0; - virtual void DropShield(bool bDeploy = true) = 0; - virtual void DropPlayerItem(const char *pszItemName) = 0; + virtual CBaseEntity *DropShield(bool bDeploy = true) = 0; + virtual CBaseEntity *DropPlayerItem(const char *pszItemName) = 0; virtual bool RemoveShield() = 0; virtual void RemoveAllItems(bool bRemoveSuit) = 0; virtual bool RemovePlayerItem(const char* pszItemName) = 0; From c0ab129f386dbe3d393c5323681ad4f8f2172ca5 Mon Sep 17 00:00:00 2001 From: Javekson Date: Tue, 3 Oct 2023 18:49:59 +0400 Subject: [PATCH 2/3] Updated the return logic of rg_drop_item to return the index of the created weapon box --- .../amxmodx/scripting/include/reapi_gamedll.inc | 4 ++-- reapi/src/natives/natives_misc.cpp | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 3ea2a44c..44a441fa 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -528,9 +528,9 @@ native rg_remove_all_items(const index, const bool:removeSuit = false); * Forces the player to drop the specified item classname. * * @param index Client index -* @param item_name Item classname +* @param item_name Item classname, if no name, the active item classname * -* @return 1 on success, 0 otherwise +* @return Entity index of weaponbox, AMX_NULLENT (-1) otherwise * */ native rg_drop_item(const index, const item_name[]); diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 8d1bcb6e..d1b8b5d0 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -1018,9 +1018,9 @@ cell AMX_NATIVE_CALL rg_remove_all_items(AMX *amx, cell *params) * Forces the player to drop the specified item classname. * * @param index Client index -* @param item_name Item classname +* @param item_name Item classname, if no name, the active item classname * -* @return 1 on success, 0 otherwise +* @return Entity index of weaponbox, AMX_NULLENT (-1) otherwise * * native rg_drop_item(const index, const item_name[]); */ @@ -1034,8 +1034,12 @@ cell AMX_NATIVE_CALL rg_drop_item(AMX *amx, cell *params) CHECK_CONNECTED(pPlayer, arg_index); char item[256]; - pPlayer->CSPlayer()->DropPlayerItem(getAmxString(amx, params[arg_item_name], item)); - return TRUE; + auto pEntity = pPlayer->CSPlayer()->DropPlayerItem(getAmxString(amx, params[arg_item_name], item)); + + if (pEntity) + return indexOfPDataAmx(pEntity); + + return AMX_NULLENT; } /* From b75f3d6d60b13335d3fc1d94909ccfb4650e7438 Mon Sep 17 00:00:00 2001 From: Javekson Date: Wed, 4 Oct 2023 13:50:00 +0400 Subject: [PATCH 3/3] Updated the return logic of rg_drop_items_by_slot --- .../extra/amxmodx/scripting/include/reapi_gamedll.inc | 3 ++- reapi/src/natives/natives_misc.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 44a441fa..30ea4a1c 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -510,7 +510,8 @@ native rg_remove_items_by_slot(const index, const InventorySlotType:slot, const * @param index Client index * @param slot Specific slot for remove of each item. * -* @return 1 on success, 0 otherwise +* @return 1 - successful drop of all items in the slot or the slot is empty +* 0 - if at least one item failed to drop */ native rg_drop_items_by_slot(const index, const InventorySlotType:slot); diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index d1b8b5d0..bceff1b3 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -970,7 +970,8 @@ cell AMX_NATIVE_CALL rg_remove_items_by_slot(AMX *amx, cell *params) * @param index Client index * @param slot Specific slot for remove of each item. * -* @return 1 on success, 0 otherwise +* @return 1 - successful drop of all items in the slot or the slot is empty +* 0 - if at least one item failed to drop * * native rg_drop_items_by_slot(const index, const InventorySlotType:slot); */ @@ -983,12 +984,14 @@ cell AMX_NATIVE_CALL rg_drop_items_by_slot(AMX *amx, cell *params) CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]); CHECK_CONNECTED(pPlayer, arg_index); - pPlayer->ForEachItem(params[arg_slot], [pPlayer](CBasePlayerItem *pItem) { - pPlayer->CSPlayer()->DropPlayerItem(STRING(pItem->pev->classname)); + bool success = true; + + pPlayer->ForEachItem(params[arg_slot], [&](CBasePlayerItem *pItem) { + success &= pPlayer->CSPlayer()->DropPlayerItem(STRING(pItem->pev->classname)) ? true : false; return false; }); - return TRUE; + return success ? TRUE : FALSE; } /*