From bfdd5cb5674be57304082f489618bca974a48fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Lo=20Giudice?= Date: Tue, 21 Mar 2017 11:50:52 -0300 Subject: [PATCH] Allow get WEAPON_C4 & WEAPON_KNIFE info (#52) * Allow get WEAPON_C4 & WEAPON_KNIFE info --- reapi/src/natives/natives_misc.cpp | 4 ++-- reapi/src/reapi_utils.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 5dd85df..626b2d8 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -661,7 +661,7 @@ cell AMX_NATIVE_CALL rg_get_weapon_info(AMX *amx, cell *params) WeaponIdType weaponID = static_cast(*getAmxAddr(amx, params[arg_weapon_id])); WpnInfo info_type = static_cast(*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(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; diff --git a/reapi/src/reapi_utils.h b/reapi/src/reapi_utils.h index 17772ff..96403c6 100644 --- a/reapi/src/reapi_utils.h +++ b/reapi/src/reapi_utils.h @@ -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 (set_info && (wpnid == WEAPON_KNIFE || wpnid == WEAPON_C4)) + return false; - if (wpnid > WEAPON_NONE && wpnid != WEAPON_C4 && wpnid != WEAPON_KNIFE && wpnid <= WEAPON_P90) + if (WEAPON_NONE < wpnid && wpnid <= WEAPON_P90) return true; return false;