From e0ad0580c381437689df1949aa0c8c401a21372c Mon Sep 17 00:00:00 2001 From: Javekson Date: Mon, 20 Nov 2023 15:49:07 +0400 Subject: [PATCH 1/3] feat(api): add WI_SLOT for rg_get_weapon_info Fixes #272 --- .../scripting/include/reapi_gamedll_const.inc | 10 +++++++++- reapi/src/natives/natives_misc.cpp | 15 +++++++++++++++ reapi/src/natives/natives_misc.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index a4a34e8e..498d8d20 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -134,7 +134,15 @@ enum WpnInfo * Get params: rg_get_weapon_info(const weapon_id, WI_NAME, const output[], maxlenght); * Set params: - */ - WI_NAME + WI_NAME, + + /* + * Description: - + * Return type: enum InventorySlotType + * Get params: rg_get_weapon_info(const weapon_id, WI_SLOT); + * Set params: rg_set_weapon_info(const weapon_id, WI_SLOT, const value); + */ + WI_SLOT }; /** diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 15f85ea7..ca596709 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -838,7 +838,16 @@ cell AMX_NATIVE_CALL rg_get_weapon_info(AMX *amx, cell *params) setAmxString(dest, info->entityName, length); return 1; } + case WI_SLOT: + { + auto pInfo = g_ReGameApi->GetWeaponSlot(weaponId); + + if (pInfo) { + return pInfo->slot; + } + return NONE_SLOT; + } default: AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: unknown type statement %i, params count %i", __FUNCTION__, info_type, PARAMS_COUNT); return -1; @@ -894,6 +903,12 @@ cell AMX_NATIVE_CALL rg_set_weapon_info(AMX *amx, cell *params) case WI_NAME: AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: this change will have no effect, type statement %i", __FUNCTION__, info_type); return 0; + case WI_SLOT: + { + auto pInfo = g_ReGameApi->GetWeaponSlot(weaponId); + pInfo->slot = static_cast(*value); + break; + } default: AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: unknown type statement %i, params count %i", __FUNCTION__, info_type, PARAMS_COUNT); return 0; diff --git a/reapi/src/natives/natives_misc.h b/reapi/src/natives/natives_misc.h index 70ca2131..1ad58361 100644 --- a/reapi/src/natives/natives_misc.h +++ b/reapi/src/natives/natives_misc.h @@ -18,6 +18,7 @@ enum WpnInfo WI_AMMO_TYPE, WI_AMMO_NAME, WI_NAME, + WI_SLOT, }; void RegisterNatives_Misc(); From 916892afdbc986f6b4ec160e25cbf93514a253be Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Mon, 20 Nov 2023 15:19:01 +0300 Subject: [PATCH 2/3] Update reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc --- reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 498d8d20..c81881a2 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -142,7 +142,7 @@ enum WpnInfo * Get params: rg_get_weapon_info(const weapon_id, WI_SLOT); * Set params: rg_set_weapon_info(const weapon_id, WI_SLOT, const value); */ - WI_SLOT + WI_SLOT, }; /** From 5b74e10faa54f8866e0eb090779b63b233acd726 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 1 Feb 2024 12:23:30 +0700 Subject: [PATCH 3/3] Cleanup --- reapi/src/natives/natives_misc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index ca596709..e94f3542 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -841,7 +841,6 @@ cell AMX_NATIVE_CALL rg_get_weapon_info(AMX *amx, cell *params) case WI_SLOT: { auto pInfo = g_ReGameApi->GetWeaponSlot(weaponId); - if (pInfo) { return pInfo->slot; } @@ -907,7 +906,7 @@ cell AMX_NATIVE_CALL rg_set_weapon_info(AMX *amx, cell *params) { auto pInfo = g_ReGameApi->GetWeaponSlot(weaponId); pInfo->slot = static_cast(*value); - break; + break; } default: AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: unknown type statement %i, params count %i", __FUNCTION__, info_type, PARAMS_COUNT);