diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc
index 85d4421..a5d935a 100644
--- a/reapi/extra/amxmodx/scripting/include/reapi.inc
+++ b/reapi/extra/amxmodx/scripting/include/reapi.inc
@@ -42,7 +42,7 @@ enum members_tables_e
};
// is like FNullEnt
-#define is_nullent(%0) (is_entity(%0) == false)
+#define is_nullent(%0) (%0 != 0 && is_entity(%0) == false)
#define MAX_REGION_RANGE 1024
@@ -148,6 +148,15 @@ native any:GetHookChainReturn(AType:type, any:...);
*/
native SetHookChainArg(number, AType:type, any:...);
+/*
+* Compares the entity to specified a classname.
+* @note This native also checks the validity of an entity.
+*
+* @return true/false
+*
+*/
+native bool:FClassnameIs(const entityIndex, const className[]);
+
/*
* Check if the entity is valid
*
diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
index 21a191f..6754522 100644
--- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
+++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
@@ -672,7 +672,7 @@ native rg_reset_maxspeed(const index);
* @noreturn
*
*/
-native rg_send_bartime(const index, const Float:duration, const bool:observer = true);
+native rg_send_bartime(const index, const duration, const bool:observer = true);
/*
* Same as BarTime, but StartPercent specifies how much of the bar is (already) filled.
@@ -685,7 +685,7 @@ native rg_send_bartime(const index, const Float:duration, const bool:observer =
* @noreturn
*
*/
-native rg_send_bartime2(const index, const Float:duration, const Float:startPercent, const bool:observer = true);
+native rg_send_bartime2(const index, const duration, const startPercent, const bool:observer = true);
/*
* Sends the message SendAudio - plays the specified audio
diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
index 3249424..4c1ec4d 100644
--- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
+++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
@@ -452,7 +452,7 @@ enum GamedllFunc_CBasePlayer
/*
* Description: The player uses a radio message.
* It is called self-uses radio or throw grenades or on freeze the period end.
- * Params: (const this, const msg_id[], const char msg_verbose[], pitch, bool:showIcon)
+ * Params: (const this, const msg_id[], const msg_verbose[], pitch, bool:showIcon)
*/
RG_CBasePlayer_Radio,
diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj
index cf715e0..6e3ac38 100644
--- a/reapi/msvc/reapi.vcxproj
+++ b/reapi/msvc/reapi.vcxproj
@@ -208,6 +208,7 @@
+
@@ -250,6 +251,7 @@
+
diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters
index c2a7ac8..7b01c75 100644
--- a/reapi/msvc/reapi.vcxproj.filters
+++ b/reapi/msvc/reapi.vcxproj.filters
@@ -666,6 +666,9 @@
version
+
+ src\natives
+
@@ -749,6 +752,9 @@
version
+
+ src\natives
+
diff --git a/reapi/src/amxxmodule.cpp b/reapi/src/amxxmodule.cpp
index 354f2b6..82c7c09 100644
--- a/reapi/src/amxxmodule.cpp
+++ b/reapi/src/amxxmodule.cpp
@@ -165,6 +165,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
RegisterNatives_Members();
RegisterNatives_Misc();
RegisterNatives_Addons();
+ RegisterNatives_Common();
return AMXX_OK;
}
diff --git a/reapi/src/member_list.cpp b/reapi/src/member_list.cpp
index f9675e4..95d4d5c 100644
--- a/reapi/src/member_list.cpp
+++ b/reapi/src/member_list.cpp
@@ -8,24 +8,24 @@
#define decltypefx(cx, pref, dt, mx) decltype(cx::pref##mx)
#endif
-#define CLASS_MEMBERS(cx, mx, postf, pref, mtbl) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, pref, ., mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##pref##mx);ptr->type = getMemberType(f);ptr->name = #postf;ptr->table = memberlist_t::members_tables_e::mtbl;}) : regmember(#pref#mx)
+#define CLASS_MEMBERS(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, pref, ., mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##pref##mx);ptr->type = getMemberType(f);ptr->name = #postf;}) : regmember(#pref#mx)
-#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx, , mt_gamerules)
-#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx, m_VoiceGameMgr., mt_gamerules)
-#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx, mx, , mt_base)
-#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx, mx, , mt_animating)
-#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx, mx, , mt_basemonster)
-#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx, mx, , mt_player)
-#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx, var_##mx, , mt_entvars)
-#define PMOVE_MEMBERS(mx) CLASS_MEMBERS(com_playermove, mx, pm_##mx, , mt_playermove)
-#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, mx, mv_##mx, , mt_movevars)
-#define UCMD_MEMBERS(mx) CLASS_MEMBERS(usercmd_s, mx, ucmd_##mx, , mt_usercmd)
-#define PMTRACE_MEMBERS(mx) CLASS_MEMBERS(pmtrace_s, mx, pmt_##mx, , mt_pmtrace)
-#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx, , mt_csplayer)
-#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx, , mt_baseitem)
-#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerWeapon, mx, m_Weapon_##mx, m_, mt_baseweapon)
-#define WPNBOX_MEMBERS(mx) CLASS_MEMBERS(CWeaponBox_COM, mx, m_WeaponBox_##mx, m_, mt_weaponbox)
-#define ARMOURY_MEMBERS(mx) CLASS_MEMBERS(CArmoury, mx, m_Armoury_##mx, m_, mt_armoury)
+#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx,)
+#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx, m_VoiceGameMgr.)
+#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx, mx,)
+#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx, mx,)
+#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx, mx,)
+#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx, mx,)
+#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx, var_##mx,)
+#define PMOVE_MEMBERS(mx) CLASS_MEMBERS(com_playermove, mx, pm_##mx,)
+#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, mx, mv_##mx,)
+#define UCMD_MEMBERS(mx) CLASS_MEMBERS(usercmd_s, mx, ucmd_##mx,)
+#define PMTRACE_MEMBERS(mx) CLASS_MEMBERS(pmtrace_s, mx, pmt_##mx,)
+#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx,)
+#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx,)
+#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerWeapon, mx, m_Weapon_##mx, m_)
+#define WPNBOX_MEMBERS(mx) CLASS_MEMBERS(CWeaponBox_COM, mx, m_WeaponBox_##mx, m_)
+#define ARMOURY_MEMBERS(mx) CLASS_MEMBERS(CArmoury, mx, m_Armoury_##mx, m_)
inline MType getMemberType(float*) { return MEMBER_FLOAT; }
inline MType getMemberType(float) { return MEMBER_FLOAT; }
diff --git a/reapi/src/member_list.h b/reapi/src/member_list.h
index ef8e390..2ffdb79 100644
--- a/reapi/src/member_list.h
+++ b/reapi/src/member_list.h
@@ -52,7 +52,7 @@ struct memberlist_t
struct member_t
{
- bool hasTable(memberlist_t::members_tables_e tbl) const;
+ bool hasTable(size_t members, memberlist_t::members_tables_e tbl) const;
bool isTypeReturnable() const;
uint16 size;
@@ -60,11 +60,11 @@ struct member_t
uint32 offset;
const char *name;
MType type;
- memberlist_t::members_tables_e table;
};
-inline bool member_t::hasTable(memberlist_t::members_tables_e tbl) const
+inline bool member_t::hasTable(size_t members, memberlist_t::members_tables_e tbl) const
{
+ const auto table = memberlist_t::members_tables_e(members / MAX_REGION_RANGE);
if (likely(table != tbl))
return false;
diff --git a/reapi/src/natives/natives_common.cpp b/reapi/src/natives/natives_common.cpp
new file mode 100644
index 0000000..917f5fd
--- /dev/null
+++ b/reapi/src/natives/natives_common.cpp
@@ -0,0 +1,125 @@
+#include "precompiled.h"
+
+/*
+* Compares the entity to specified a classname.
+* @note This native also checks the validity of an entity.
+*
+* @return true/false
+*
+* native bool:FClassnameIs(const entityIndex, const className[]);
+*/
+cell AMX_NATIVE_CALL amx_FClassnameIs(AMX *amx, cell *params)
+{
+ enum args_e { arg_count, arg_index, arg_classname };
+
+ int nEntityIndex = params[arg_index];
+ if (nEntityIndex < 0 || nEntityIndex > gpGlobals->maxEntities) {
+ return FALSE;
+ }
+
+ edict_t *pEdict = edictByIndex(nEntityIndex);
+ if (pEdict && FClassnameIs(pEdict, getAmxString(amx, params[arg_classname]))) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+AMX_NATIVE_INFO Natives_Common[] =
+{
+ { "FClassnameIs", amx_FClassnameIs },
+
+ { nullptr, nullptr }
+};
+
+/*
+* Check if the entity is valid
+*
+* @return true/false
+*
+* native bool:is_entity(const entityIndex);
+*/
+cell AMX_NATIVE_CALL is_entity(AMX *amx, cell *params)
+{
+ enum args_e { arg_count, arg_index };
+
+ int nIndex = params[arg_index];
+ if (nIndex < 0 || nIndex > gpGlobals->maxEntities) {
+ return FALSE;
+ }
+
+ auto pEntity = getPrivate(nIndex);
+ if (!pEntity) {
+ return FALSE;
+ }
+
+ // if it is the index of the player
+ if (pEntity->IsPlayer() && pEntity->has_disconnected) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+* Check if the rehlds is available
+*
+* @return true/false
+*
+* native bool:is_rehlds();
+*/
+cell AMX_NATIVE_CALL is_rehlds(AMX *amx, cell *params)
+{
+ return (cell)api_cfg.hasReHLDS();
+}
+
+/*
+* Check if the regamedll is available
+*
+* @return true/false
+*
+* native bool:is_regamedll();
+*/
+cell AMX_NATIVE_CALL is_regamedll(AMX *amx, cell *params)
+{
+ return (cell)api_cfg.hasReGameDLL();
+}
+
+/*
+* Check if the reunion is available
+*
+* @return true/false
+*
+* native bool:is_has_reunion();
+*/
+cell AMX_NATIVE_CALL has_reunion(AMX *amx, cell *params)
+{
+ return (cell)api_cfg.hasReunion();
+}
+
+/*
+* Check if the vtc is available
+*
+* @return true/false
+*
+* native bool:is_has_vtc();
+*/
+cell AMX_NATIVE_CALL has_vtc(AMX *amx, cell *params)
+{
+ return (cell)api_cfg.hasVTC();
+}
+
+AMX_NATIVE_INFO Natives_Checks[] =
+{
+ { "is_entity", is_entity },
+ { "is_rehlds", is_rehlds },
+ { "is_regamedll", is_regamedll },
+ { "has_reunion", has_reunion },
+ { "has_vtc", has_vtc }
+};
+
+void RegisterNatives_Common()
+{
+ g_amxxapi.AddNatives(Natives_Common);
+ g_amxxapi.AddNatives(Natives_Checks);
+}
diff --git a/reapi/src/natives/natives_common.h b/reapi/src/natives/natives_common.h
new file mode 100644
index 0000000..7dae493
--- /dev/null
+++ b/reapi/src/natives/natives_common.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void RegisterNatives_Common();
diff --git a/reapi/src/natives/natives_members.cpp b/reapi/src/natives/natives_members.cpp
index 5f32709..39d82df 100644
--- a/reapi/src/natives/natives_members.cpp
+++ b/reapi/src/natives/natives_members.cpp
@@ -20,7 +20,7 @@ cell AMX_NATIVE_CALL set_member(AMX *amx, cell *params)
cell* value = getAmxAddr(amx, params[arg_value]);
size_t element = (PARAMS_COUNT == 4) ? *getAmxAddr(amx, params[arg_elem]) : 0;
- if (member->hasTable(memberlist_t::mt_csplayer)) {
+ if (member->hasTable(params[arg_member], memberlist_t::mt_csplayer)) {
CBasePlayer *pPlayer = (CBasePlayer *)pEdict->pvPrivateData;
if (unlikely(pPlayer->CSPlayer() == nullptr)) {
return FALSE;
@@ -86,7 +86,7 @@ cell AMX_NATIVE_CALL get_member(AMX *amx, cell *params)
break;
}
- if (member->hasTable(memberlist_t::mt_csplayer)) {
+ if (member->hasTable(params[arg_member], memberlist_t::mt_csplayer)) {
CBasePlayer *pPlayer = (CBasePlayer *)pEdict->pvPrivateData;
if (unlikely(pPlayer->CSPlayer() == nullptr)) {
return FALSE;
diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp
index 95aa27e..50c19b1 100644
--- a/reapi/src/natives/natives_misc.cpp
+++ b/reapi/src/natives/natives_misc.cpp
@@ -1338,10 +1338,9 @@ cell AMX_NATIVE_CALL rg_transfer_c4(AMX *amx, cell *params)
CBasePlayer *pReceiver = UTIL_PlayerByIndex(params[arg_receiver]);
CHECK_CONNECTED(pReceiver, arg_receiver);
- pReceiver->m_bHasC4 = true;
- pReceiver->CSPlayer()->GiveNamedItemEx("weapon_c4");
- pReceiver->CSPlayer()->SetBombIcon();
- pReceiver->pev->body = 1;
+ if (!pReceiver->CSPlayer()->MakeBomber())
+ return FALSE;
+
} else {
auto flags = pPlayer->pev->flags;
pPlayer->pev->flags |= FL_DORMANT;
@@ -1663,7 +1662,7 @@ cell AMX_NATIVE_CALL rg_reset_maxspeed(AMX *amx, cell *params)
*
* @noreturn
*
-* native rg_send_bartime(const index, const Float:duration, const bool:observer = true);
+* native rg_send_bartime(const index, const duration, const bool:observer = true);
*/
cell AMX_NATIVE_CALL rg_send_bartime(AMX *amx, cell *params)
{
@@ -1694,7 +1693,7 @@ cell AMX_NATIVE_CALL rg_send_bartime(AMX *amx, cell *params)
*
* @noreturn
*
-* native rg_send_bartime2(const index, const Float:duration, const Float:startPercent, const bool:observer = true);
+* native rg_send_bartime2(const index, const duration, const startPercent, const bool:observer = true);
*/
cell AMX_NATIVE_CALL rg_send_bartime2(AMX *amx, cell *params)
{
@@ -1960,92 +1959,6 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
{ nullptr, nullptr }
};
-/*
-* Check if the entity is valid
-*
-* @return true/false
-*
-* native bool:is_entity(const entityIndex);
-*/
-cell AMX_NATIVE_CALL is_entity(AMX *amx, cell *params)
-{
- enum args_e { arg_count, arg_index };
-
- int nIndex = params[arg_index];
- if (nIndex < 0 || nIndex > gpGlobals->maxEntities) {
- return FALSE;
- }
-
- auto pEntity = getPrivate(nIndex);
- if (!pEntity) {
- return FALSE;
- }
-
- // if it is the index of the player
- if (pEntity->IsPlayer() && pEntity->has_disconnected) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
-* Check if the rehlds is available
-*
-* @return true/false
-*
-* native bool:is_rehlds();
-*/
-cell AMX_NATIVE_CALL is_rehlds(AMX *amx, cell *params)
-{
- return (cell)api_cfg.hasReHLDS();
-}
-
-/*
-* Check if the regamedll is available
-*
-* @return true/false
-*
-* native bool:is_regamedll();
-*/
-cell AMX_NATIVE_CALL is_regamedll(AMX *amx, cell *params)
-{
- return (cell)api_cfg.hasReGameDLL();
-}
-
-/*
-* Check if the reunion is available
-*
-* @return true/false
-*
-* native bool:is_has_reunion();
-*/
-cell AMX_NATIVE_CALL has_reunion(AMX *amx, cell *params)
-{
- return (cell)api_cfg.hasReunion();
-}
-
-/*
-* Check if the vtc is available
-*
-* @return true/false
-*
-* native bool:is_has_vtc();
-*/
-cell AMX_NATIVE_CALL has_vtc(AMX *amx, cell *params)
-{
- return (cell)api_cfg.hasVTC();
-}
-
-AMX_NATIVE_INFO Misc_Natives_Checks[] =
-{
- { "is_entity", is_entity },
- { "is_rehlds", is_rehlds },
- { "is_regamedll", is_regamedll },
- { "has_reunion", has_reunion },
- { "has_vtc", has_vtc }
-};
-
void RegisterNatives_Misc()
{
if (!api_cfg.hasReGameDLL())
@@ -2056,5 +1969,4 @@ void RegisterNatives_Misc()
g_amxxapi.AddNatives(Misc_Natives_RG);
g_amxxapi.AddNatives(Misc_Natives_RH);
- g_amxxapi.AddNatives(Misc_Natives_Checks);
}
diff --git a/reapi/src/precompiled.h b/reapi/src/precompiled.h
index 63d57e1..eed05cd 100644
--- a/reapi/src/precompiled.h
+++ b/reapi/src/precompiled.h
@@ -60,5 +60,6 @@
#include "natives_hookchains.h"
#include "natives_members.h"
#include "natives_misc.h"
+#include "natives_common.h"
#include "natives_addons.h"
#include "natives_helper.h"