Code:
#include <amxmodx>
#include <amxmisc>
#include <okapi>
public plugin_init()
{
new NET_IsLocalAddress[] = {0x55,0x8B,0xEC,0x8B,0x4D,0xDEF,0x33,0xC0,0x83,0xF9,0xDEF,0x0F,0x94,0xC0,0x5D,0xC3};
new address = okapi_engine_find_sig( NET_IsLocalAddress, sizeof NET_IsLocalAddress );
new okapi_func:function = okapi_build_function( address, arg_int /* return */, arg_int /* type */, arg_int /* ip */, arg_int /* ipx_1 */, arg_int /* ipx_2 */, arg_int /* ipx _3 + port */ );
okapi_add_hook( function, "OnNET_IsLocalAddress_Post", true );
}
public OnNET_IsLocalAddress_Post( na_type, na_ip, na_dummy_1, na_dummy_2, na_ipxport )
{
new ip_port[ 20 ];
get_client_ip( na_ip, na_ipxport, ip_port, charsmax( ip_port ), .with_port = true );
log_amx( "ip_port = %s", ip_port );
}
get_client_ip( const na_ip, const na_ipxport, ip[], const ip_length, const bool:with_port = false )
{
new length = formatex( ip, ip_length, "%d.%d.%d.%d",
na_ip % 0x100,
( na_ip / 0x100 ) % 0x100,
( na_ip / 0x10000 ) % 0x100,
( na_ip / 0x1000000 ) % 0x100 );
with_port && formatex( ip[ length ], ip_length - length, ":%d",
( ( ( na_ipxport / 0x10000 ) % 0x100 ) * 0x100 ) + ( ( na_ipxport / 0x10000 ) / 0x100 ) );
}