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

how to get players IP?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DigiSoft
BANNED
Join Date: Feb 2009
Old 01-06-2010 , 09:08   how to get players IP?
Reply With Quote #1

Ok so it is me again.

Can you please tell me how can I get user IP?

Thank you.

Last edited by DigiSoft; 01-06-2010 at 09:59.
DigiSoft is offline
Keeper
Senior Member
Join Date: Nov 2006
Old 01-06-2010 , 10:18   Re: how to get players IP?
Reply With Quote #2

INetChannelInfo *nci = engine->GetPlayerNetInfo(playerindex);

Then GetPlayerNetInfo has a GetAddress method ... but I think that returns the port as well i.e. 192.168.1.7:27005
Keeper is offline
DigiSoft
BANNED
Join Date: Feb 2009
Old 01-06-2010 , 10:27   Re: how to get players IP?
Reply With Quote #3

when i try nci-> nothing returns in Visual Studio so I don't know how to get the IP.

Last edited by DigiSoft; 01-06-2010 at 10:30.
DigiSoft is offline
Keeper
Senior Member
Join Date: Nov 2006
Old 01-06-2010 , 10:35   Re: how to get players IP?
Reply With Quote #4

it would be:
Code:
const char *ip = nci->GetAddress();
Keeper is offline
DigiSoft
BANNED
Join Date: Feb 2009
Old 01-06-2010 , 10:51   Re: how to get players IP?
Reply With Quote #5

Oh thank you I also forgot to include inetchannelinfo.h.

Now it works.

Thank you again.
DigiSoft is offline
DigiSoft
BANNED
Join Date: Feb 2009
Old 01-06-2010 , 11:12   Re: how to get players IP?
Reply With Quote #6

When I do this it compiles ok but when I join the server, the server crashes with some memory location error.

It crashes on this line

const char *address = netinfo->GetAddress();

WHY?

EDIT1:
I think I don't pass valid edict.

OK SO I have main loop which checks for number of players and then takes one by one and checks his IP. I am doing it like this.

Quote:
edict_t* pEntity = engine->PEntityOfEntIndex(i);
INetChannelInfo *netinfo = engine->GetPlayerNetInfo(engine->IndexOfEdict(pEntity));
const char *address = netinfo->GetAddress();
"i" is used in the "for" loop.

Am I doing something wrong?

on load I have this plugins
Quote:
if( !(engine = (IVEngineServer*)interfaceFactory(INTERFACEVE RSION_VENGINESERVER, NULL)) ||
!(gameeventmanager = (IGameEventManager *)interfaceFactory(INTERFACEVERSION_GAMEEVENT SMANAGER,NULL)) ||
!(filesystem = (IFileSystem*)interfaceFactory(FILESYSTEM_INT ERFACE_VERSION, NULL)) ||
!(helpers = (IServerPluginHelpers*)interfaceFactory(INTER FACEVERSION_ISERVERPLUGINHELPERS, NULL)) ||
!(enginetrace = (IEngineTrace *)interfaceFactory(INTERFACEVERSION_ENGINETRA CE_SERVER,NULL)) ||
!(randomStr = (IUniformRandomStream *)interfaceFactory(VENGINE_SERVER_RANDOM_INTE RFACE_VERSION, NULL))
)
Should I write new line for INetChannelInfo ?

Last edited by DigiSoft; 01-06-2010 at 11:30.
DigiSoft is offline
Keeper
Senior Member
Join Date: Nov 2006
Old 01-06-2010 , 11:31   Re: how to get players IP?
Reply With Quote #7

you will need to test the entity before getting the netinfo
Code:
if(pEntity && !pEntity->IsFree() ) {
    INetChannelInfo *netinfo = engine->GetPlayerNetInfo(i);
    const char *address = netinfo->GetAddress();                      
}

Last edited by Keeper; 01-06-2010 at 11:33.
Keeper is offline
DigiSoft
BANNED
Join Date: Feb 2009
Old 01-06-2010 , 11:44   Re: how to get players IP?
Reply With Quote #8

No, it still crashes :S :S :S :S

The error message is

The instruction at "0x12555f8f" referenced memory at "0x00000010". The memory could not be "read".

This sounds to me like I havent some constructor. HELP?
DigiSoft is offline
Keeper
Senior Member
Join Date: Nov 2006
Old 01-06-2010 , 11:46   Re: how to get players IP?
Reply With Quote #9

This would be an easy place to debug. Do you have it set up for debugging?
Keeper is offline
DigiSoft
BANNED
Join Date: Feb 2009
Old 01-06-2010 , 11:51   Re: how to get players IP?
Reply With Quote #10

Ahhhh I am little noob to debugging.

Arghhhh I really don't know why it crashes.

It crashes on netinfo->GetAddress()

Last edited by DigiSoft; 01-06-2010 at 11:57.
DigiSoft is offline
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 03:55.


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