diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc
index 8b797c3..52c17a5 100644
--- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc
+++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc
@@ -148,3 +148,14 @@ native rh_update_user_info(playerEntIndex);
*
*/
native rh_drop_client(const index, const message[] = "");
+
+/*
+* -
+*
+* @param output Buffer to copy the ip address
+* @param len Maximum buffer size
+*
+* @noreturn
+*
+*/
+native rh_get_net_from(output[], len);
diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj
index 0877c6b..5fdef54 100644
--- a/reapi/msvc/reapi.vcxproj
+++ b/reapi/msvc/reapi.vcxproj
@@ -366,7 +366,7 @@
Windows
true
- %(AdditionalDependencies)
+ ws2_32.lib;%(AdditionalDependencies)
reapi.def
@@ -420,7 +420,7 @@
true
true
true
- %(AdditionalDependencies)
+ ws2_32.lib;%(AdditionalDependencies)
reapi.def
diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp
index a52d6af..d06a122 100644
--- a/reapi/src/natives/natives_misc.cpp
+++ b/reapi/src/natives/natives_misc.cpp
@@ -2723,6 +2723,28 @@ cell AMX_NATIVE_CALL rh_drop_client(AMX *amx, cell *params)
return TRUE;
}
+/*
+* -
+*
+* @param output Buffer to copy the ip address
+* @param len Maximum buffer size
+*
+* @noreturn
+*
+* native rh_get_net_from(output[], len);
+*/
+cell AMX_NATIVE_CALL rh_get_net_from(AMX* amx, cell* params)
+{
+ enum args_e { arg_count, arg_output, arg_maxlen };
+
+ cell *dest = getAmxAddr(amx, params[arg_output]);
+ char *addr = NET_AdrToString(*g_RehldsData->GetNetFrom());
+
+ setAmxString(dest, addr, params[arg_maxlen]);
+
+ return TRUE;
+}
+
AMX_NATIVE_INFO Misc_Natives_RH[] =
{
{ "rh_set_mapname", rh_set_mapname },
@@ -2731,6 +2753,7 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
{ "rh_emit_sound2", rh_emit_sound2 },
{ "rh_update_user_info", rh_update_user_info },
{ "rh_drop_client", rh_drop_client },
+ { "rh_get_net_from", rh_get_net_from },
{ nullptr, nullptr }
};
diff --git a/reapi/src/reapi_utils.cpp b/reapi/src/reapi_utils.cpp
index 77c0693..2d30416 100644
--- a/reapi/src/reapi_utils.cpp
+++ b/reapi/src/reapi_utils.cpp
@@ -240,3 +240,22 @@ const char *getATypeStr(AType type)
return s_ATypes[type];
}
+
+char* NET_AdrToString(const netadr_t& a)
+{
+ static char s[64];
+
+ Q_memset(s, 0, sizeof(s));
+
+ if (a.type == NA_LOOPBACK)
+ Q_snprintf(s, sizeof(s), "loopback");
+ else if (a.type == NA_IP)
+ Q_snprintf(s, sizeof(s), "%i.%i.%i.%i:%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3], ntohs(a.port));
+#ifdef _WIN32
+ else // NA_IPX
+ Q_snprintf(s, sizeof(s), "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%i", a.ipx[0], a.ipx[1], a.ipx[2], a.ipx[3], a.ipx[4], a.ipx[5], a.ipx[6], a.ipx[7], a.ipx[8], a.ipx[9], ntohs(a.port));
+#endif // _WIN32
+
+ return s;
+}
+
diff --git a/reapi/src/reapi_utils.h b/reapi/src/reapi_utils.h
index 86a8adf..994864c 100644
--- a/reapi/src/reapi_utils.h
+++ b/reapi/src/reapi_utils.h
@@ -59,4 +59,6 @@ void RemoveOrDropItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, GiveType typ
const char *getATypeStr(AType type);
+char *NET_AdrToString(const netadr_t& a);
+
extern void NORETURN UTIL_SysError(const char *fmt, ...);