2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-01-28 14:37:57 +03:00

Added a new argument removeAmmo to the rg_remove_items_by_slot native (#283)

This commit is contained in:
Javekson 2023-09-05 18:11:49 +04:00 committed by GitHub
parent 463799748e
commit 4ef19557c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -496,12 +496,13 @@ native rg_set_weapon_info(const {WeaponIdType,_}:weapon_id, WpnInfo:type, any:..
/* /*
* Remove all the player's stuff in a specific slot. * Remove all the player's stuff in a specific slot.
* *
* @param index Client index * @param index Client index
* @param slot The slot that will be emptied * @param slot The slot that will be emptied
* @param removeAmmo Remove ammunition
* *
* @return 1 on success, 0 otherwise * @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. * Drop to floor all the player's stuff by specific slot.

View File

@ -905,16 +905,17 @@ cell AMX_NATIVE_CALL rg_set_weapon_info(AMX *amx, cell *params)
/* /*
* Remove all the player's stuff in a specific slot. * Remove all the player's stuff in a specific slot.
* *
* @param index Client index * @param index Client index
* @param slot The slot that will be emptied * @param slot The slot that will be emptied
* @param removeAmmo Remove ammunition
* *
* @return 1 on success, 0 otherwise * @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) 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); CHECK_ISPLAYER(arg_index);
@ -927,14 +928,18 @@ cell AMX_NATIVE_CALL rg_remove_items_by_slot(AMX *amx, cell *params)
} }
else else
{ {
pPlayer->ForEachItem(params[arg_slot], [pPlayer](CBasePlayerItem *pItem) pPlayer->ForEachItem(params[arg_slot], [pPlayer, params](CBasePlayerItem *pItem)
{ {
if (pItem->IsWeapon()) { if (pItem->IsWeapon()) {
if (pItem == pPlayer->m_pActiveItem) { if (pItem == pPlayer->m_pActiveItem) {
((CBasePlayerWeapon *)pItem)->RetireWeapon(); ((CBasePlayerWeapon *)pItem)->RetireWeapon();
} }
pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0; // Compatible with older versions of the plugin,
// which still only pass two parameters
if (PARAMS_COUNT < 3 || params[arg_remammo]) {
pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0;
}
} }
if (pPlayer->RemovePlayerItem(pItem)) { if (pPlayer->RemovePlayerItem(pItem)) {