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

Allow get WEAPON_C4 & WEAPON_KNIFE info (#52)

* Allow get WEAPON_C4 & WEAPON_KNIFE info
This commit is contained in:
Iván Lo Giudice 2017-03-21 11:50:52 -03:00 committed by s1lentq
parent 6df3e41c02
commit bfdd5cb567
2 changed files with 7 additions and 4 deletions

View File

@ -661,7 +661,7 @@ cell AMX_NATIVE_CALL rg_get_weapon_info(AMX *amx, cell *params)
WeaponIdType weaponID = static_cast<WeaponIdType>(*getAmxAddr(amx, params[arg_weapon_id]));
WpnInfo info_type = static_cast<WpnInfo>(*getAmxAddr(amx, params[arg_type]));
if (!GetWeaponInfoRange(weaponID) && info_type != WI_ID && weaponID != WEAPON_KNIFE)
if (!GetWeaponInfoRange(weaponID, false) && info_type != WI_ID)
{
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid weapon id %i", __FUNCTION__, weaponID);
return 0;
@ -752,7 +752,7 @@ cell AMX_NATIVE_CALL rg_set_weapon_info(AMX *amx, cell *params)
enum args_e { arg_count, arg_weapon_id, arg_type, arg_value };
WeaponIdType weaponID = static_cast<WeaponIdType>(params[arg_weapon_id]);
if (!GetWeaponInfoRange(weaponID))
if (!GetWeaponInfoRange(weaponID, true))
{
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid weapon id %i", __FUNCTION__, weaponID);
return 0;

View File

@ -22,12 +22,15 @@ inline void EWRITE_ENTITY(int iValue) { (*g_pengfuncsTable->pfnWriteEntity)(iVal
#define _strlwr(p) for (int i = 0; p[i] != 0; i++) p[i] = tolower(p[i]);
#endif
inline bool GetWeaponInfoRange(WeaponIdType wpnid)
inline bool GetWeaponInfoRange(WeaponIdType wpnid, bool set_info)
{
if (wpnid == WEAPON_SHIELDGUN)
return true;
if (wpnid > WEAPON_NONE && wpnid != WEAPON_C4 && wpnid != WEAPON_KNIFE && wpnid <= WEAPON_P90)
if (set_info && (wpnid == WEAPON_KNIFE || wpnid == WEAPON_C4))
return false;
if (WEAPON_NONE < wpnid && wpnid <= WEAPON_P90)
return true;
return false;