Skip to content

Commit

Permalink
Enhanced rg_remove_item: add new param remove ammunition
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Feb 16, 2018
1 parent 9e41f5f commit 8d00573
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 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_internal_cmd(const index, const cmd[], const arg[] = "");
*
* @param index Client index
* @param item_name Item classname
* @param removeAmmo Remove ammunition
*
* @return 1 if found and remove, 0 otherwise
*/
native rg_remove_item(const index, const item_name[]);
native rg_remove_item(const index, const item_name[], const bool:removeAmmo = false);

/*
* Sets the amount of ammo in the client's backpack for a specific weapon.
Expand Down
1 change: 1 addition & 0 deletions reapi/include/cssdk/dlls/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CCSPlayer: public CCSMonster {
virtual bool MakeBomber();
virtual void ResetSequenceInfo();
virtual void StartDeathCam();
virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo);

CBasePlayer *BasePlayer() const;

Expand Down
2 changes: 1 addition & 1 deletion reapi/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>

#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 5
#define REGAMEDLL_API_VERSION_MINOR 6

// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
Expand Down
13 changes: 9 additions & 4 deletions reapi/msvc/reapi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<ClInclude Include="..\include\cssdk\dlls\activitymap.h" />
<ClInclude Include="..\include\cssdk\dlls\airtank.h" />
<ClInclude Include="..\include\cssdk\dlls\ammo.h" />
<ClInclude Include="..\include\cssdk\dlls\API\CSEntity.h" />
<ClInclude Include="..\include\cssdk\dlls\API\CSInterfaces.h" />
<ClInclude Include="..\include\cssdk\dlls\API\CSPlayer.h" />
<ClInclude Include="..\include\cssdk\dlls\API\CSPlayerItem.h" />
<ClInclude Include="..\include\cssdk\dlls\API\CSPlayerWeapon.h" />
<ClInclude Include="..\include\cssdk\dlls\basemonster.h" />
<ClInclude Include="..\include\cssdk\dlls\bmodels.h" />
<ClInclude Include="..\include\cssdk\dlls\bot\cs_bot.h" />
Expand Down Expand Up @@ -371,10 +376,10 @@
<Message>Force build to run Pre-Build event</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>subversion.always.run</Outputs>
<Outputs>build.always.run</Outputs>
</CustomBuildStep>
<CustomBuildStep>
<Inputs>subversion.always.run</Inputs>
<Inputs>build.always.run</Inputs>
</CustomBuildStep>
<PreBuildEvent>
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\")</Command>
Expand Down Expand Up @@ -419,10 +424,10 @@
<Message>Force build to run Pre-Build event</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>subversion.always.run</Outputs>
<Outputs>build.always.run</Outputs>
</CustomBuildStep>
<CustomBuildStep>
<Inputs>subversion.always.run</Inputs>
<Inputs>build.always.run</Inputs>
</CustomBuildStep>
<PostBuildEvent>
<Command>IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)")</Command>
Expand Down
9 changes: 5 additions & 4 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,23 +988,24 @@ cell AMX_NATIVE_CALL rg_internal_cmd(AMX *amx, cell *params)
*
* @param index Client index
* @param item_name Item classname
* @param removeAmmo Remove ammunition
*
* @return 1 if found and remove, 0 otherwise
*
* native rg_remove_item(const index, const item_name[]);
* native rg_remove_item(const index, const item_name[], const bool:removeAmmo = false);
*/
cell AMX_NATIVE_CALL rg_remove_item(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_item_name };
enum args_e { arg_count, arg_index, arg_item_name, arg_remammo };

CHECK_ISPLAYER(arg_index);

CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]);
CHECK_CONNECTED(pPlayer, arg_index);

char iname[256];
const char* szItemName = getAmxString(amx, params[arg_item_name], iname);
if (pPlayer->CSPlayer()->RemovePlayerItem(szItemName)) {
const char* pszItemName = getAmxString(amx, params[arg_item_name], iname);
if (pPlayer->CSPlayer()->RemovePlayerItemEx(pszItemName, params[arg_remammo] != 0)) {
return TRUE;
}

Expand Down

0 comments on commit 8d00573

Please sign in to comment.