Raised This Month: $51 Target: $400
 12% 

SV_ConnectClient: get joining IP


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2014 , 14:37   Re: SV_ConnectClient: get joining IP
Reply With Quote #21

Actually, I may forgot the padding (event though I've included it before).

But there is a way to get IP from NET_IsLocalAddress. Thanks to the motherfucker Joaquim, the net_adr struct is passed like each argument are passed separately. Because of the type (unsigned char, short), we need to convert and play with bits.

Here a possible way :

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 ) ); }
__________________

Last edited by Arkshine; 04-02-2014 at 14:45.
Arkshine is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 04-02-2014 , 21:06   Re: SV_ConnectClient: get joining IP
Reply With Quote #22

You did it again, it works.


If I call isLocalAddress in SV_ConnectClient I would get ip:port there, wouldn't I?

PS: I hate html tags I can't copy&paste from them.
__________________

Last edited by Neeeeeeeeeel.-; 04-02-2014 at 21:08.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-04-2014 , 13:56   Re: SV_ConnectClient: get joining IP
Reply With Quote #23

You may be confused about something. isLocalAddress returns just if address provided is local or not. We use IsLocalAddress because argument passed is a net_adr structure, which contains user's ip. So, the point is if you want to retrieve such data, you can hook this function. Basically like #5, except you need to use my method.

The other method retrieving directly net_from global variable is also fine to use.
__________________

Last edited by Arkshine; 04-04-2014 at 13:57.
Arkshine is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 04-04-2014 , 14:47   Re: SV_ConnectClient: get joining IP
Reply With Quote #24

I got it, thank you!
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode