Skip to content

Commit

Permalink
Added a new argument removeAmmo to the rg_remove_items_by_slot native
Browse files Browse the repository at this point in the history
  • Loading branch information
Javekson committed Sep 2, 2023
1 parent a60e2b5 commit 548b037
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 7 additions & 4 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion reapi/version/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

#pragma once

#define VERSION_MAJOR 5
#define VERSION_MAJOR 6
#define VERSION_MINOR 23
#define VERSION_MAINTENANCE 0

0 comments on commit 548b037

Please sign in to comment.