Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add WI_SLOT for rg_get_weapon_info #292

Merged
merged 3 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/**
Expand Down
14 changes: 14 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,15 @@ 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;
Expand Down Expand Up @@ -894,6 +902,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<InventorySlotType>(*value);
break;
}
default:
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: unknown type statement %i, params count %i", __FUNCTION__, info_type, PARAMS_COUNT);
return 0;
Expand Down
1 change: 1 addition & 0 deletions reapi/src/natives/natives_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum WpnInfo
WI_AMMO_TYPE,
WI_AMMO_NAME,
WI_NAME,
WI_SLOT,
};

void RegisterNatives_Misc();
Loading