2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Updated the return logic of rg_drop_item and rg_drop_items_by_slot (#289)

This commit is contained in:
Javekson 2023-10-07 13:23:40 +04:00 committed by GitHub
parent 2077022a43
commit e36a40c3e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 13 deletions

View File

@ -511,7 +511,8 @@ native rg_remove_items_by_slot(const index, const InventorySlotType:slot, const
* @param index Client index * @param index Client index
* @param slot Specific slot for remove of each item. * @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); native rg_drop_items_by_slot(const index, const InventorySlotType:slot);
@ -529,9 +530,9 @@ native rg_remove_all_items(const index, const bool:removeSuit = false);
* Forces the player to drop the specified item classname. * Forces the player to drop the specified item classname.
* *
* @param index Client index * @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[]); native rg_drop_item(const index, const item_name[]);

View File

@ -64,8 +64,8 @@ public:
virtual CBaseEntity *GiveNamedItemEx(const char *pszName) = 0; virtual CBaseEntity *GiveNamedItemEx(const char *pszName) = 0;
virtual void GiveDefaultItems() = 0; virtual void GiveDefaultItems() = 0;
virtual void GiveShield(bool bDeploy = true) = 0; virtual void GiveShield(bool bDeploy = true) = 0;
virtual void DropShield(bool bDeploy = true) = 0; virtual CBaseEntity *DropShield(bool bDeploy = true) = 0;
virtual void DropPlayerItem(const char *pszItemName) = 0; virtual CBaseEntity *DropPlayerItem(const char *pszItemName) = 0;
virtual bool RemoveShield() = 0; virtual bool RemoveShield() = 0;
virtual void RemoveAllItems(bool bRemoveSuit) = 0; virtual void RemoveAllItems(bool bRemoveSuit) = 0;
virtual bool RemovePlayerItem(const char* pszItemName) = 0; virtual bool RemovePlayerItem(const char* pszItemName) = 0;

View File

@ -942,7 +942,8 @@ cell AMX_NATIVE_CALL rg_remove_items_by_slot(AMX *amx, cell *params)
* @param index Client index * @param index Client index
* @param slot Specific slot for remove of each item. * @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); * native rg_drop_items_by_slot(const index, const InventorySlotType:slot);
*/ */
@ -955,12 +956,14 @@ cell AMX_NATIVE_CALL rg_drop_items_by_slot(AMX *amx, cell *params)
CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]); CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]);
CHECK_CONNECTED(pPlayer, arg_index); CHECK_CONNECTED(pPlayer, arg_index);
pPlayer->ForEachItem(params[arg_slot], [pPlayer](CBasePlayerItem *pItem) { bool success = true;
pPlayer->CSPlayer()->DropPlayerItem(STRING(pItem->pev->classname));
pPlayer->ForEachItem(params[arg_slot], [&](CBasePlayerItem *pItem) {
success &= pPlayer->CSPlayer()->DropPlayerItem(STRING(pItem->pev->classname)) ? true : false;
return false; return false;
}); });
return TRUE; return success ? TRUE : FALSE;
} }
/* /*
@ -990,9 +993,9 @@ cell AMX_NATIVE_CALL rg_remove_all_items(AMX *amx, cell *params)
* Forces the player to drop the specified item classname. * Forces the player to drop the specified item classname.
* *
* @param index Client index * @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[]); * native rg_drop_item(const index, const item_name[]);
*/ */
@ -1006,8 +1009,12 @@ cell AMX_NATIVE_CALL rg_drop_item(AMX *amx, cell *params)
CHECK_CONNECTED(pPlayer, arg_index); CHECK_CONNECTED(pPlayer, arg_index);
char item[256]; char item[256];
pPlayer->CSPlayer()->DropPlayerItem(getAmxString(amx, params[arg_item_name], item)); auto pEntity = pPlayer->CSPlayer()->DropPlayerItem(getAmxString(amx, params[arg_item_name], item));
return TRUE;
if (pEntity)
return indexOfPDataAmx(pEntity);
return AMX_NULLENT;
} }
/* /*