From 548b0375962ced78ff65e003dc439b9f24d5b2ec Mon Sep 17 00:00:00 2001 From: Javekson Date: Sat, 2 Sep 2023 18:16:33 +0400 Subject: [PATCH] Added a new argument removeAmmo to the rg_remove_items_by_slot native --- .../extra/amxmodx/scripting/include/reapi_gamedll.inc | 3 ++- reapi/src/natives/natives_misc.cpp | 11 +++++++---- reapi/version/version.h | 2 +- 3 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 984fb563..f13f5d4a 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -497,10 +497,11 @@ native rg_set_weapon_info(const {WeaponIdType,_}:weapon_id, WpnInfo:type, any:.. * * @param index Client index * @param slot The slot that will be emptied +* @param removeAmmo Remove ammunition * * @return 1 on success, 0 otherwise */ -native rg_remove_items_by_slot(const index, const InventorySlotType:slot); +native rg_remove_items_by_slot(const index, const InventorySlotType:slot, const bool:removeAmmo = true); /* * Drop to floor all the player's stuff by specific slot. diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 24b19f04..d680014b 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -906,14 +906,15 @@ cell AMX_NATIVE_CALL rg_set_weapon_info(AMX *amx, cell *params) * * @param index Client index * @param slot The slot that will be emptied +* @param removeAmmo Remove ammunition * * @return 1 on success, 0 otherwise * -* native rg_remove_items_by_slot(const index, const InventorySlotType:slot); +* native rg_remove_items_by_slot(const index, const InventorySlotType:slot, const bool:removeAmmo = true); */ cell AMX_NATIVE_CALL rg_remove_items_by_slot(AMX *amx, cell *params) { - enum args_e { arg_count, arg_index, arg_slot }; + enum args_e { arg_count, arg_index, arg_slot, arg_remammo }; CHECK_ISPLAYER(arg_index); @@ -926,14 +927,16 @@ cell AMX_NATIVE_CALL rg_remove_items_by_slot(AMX *amx, cell *params) } else { - pPlayer->ForEachItem(params[arg_slot], [pPlayer](CBasePlayerItem *pItem) + pPlayer->ForEachItem(params[arg_slot], [pPlayer, params](CBasePlayerItem *pItem) { if (pItem->IsWeapon()) { if (pItem == pPlayer->m_pActiveItem) { ((CBasePlayerWeapon *)pItem)->RetireWeapon(); } - pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0; + if (params[arg_remammo]) { + pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0; + } } if (pPlayer->RemovePlayerItem(pItem)) { diff --git a/reapi/version/version.h b/reapi/version/version.h index 554ac429..02150ef8 100644 --- a/reapi/version/version.h +++ b/reapi/version/version.h @@ -5,6 +5,6 @@ #pragma once -#define VERSION_MAJOR 5 +#define VERSION_MAJOR 6 #define VERSION_MINOR 23 #define VERSION_MAINTENANCE 0