AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   how to get players IP? (https://forums.alliedmods.net/showthread.php?t=114627)

DigiSoft 01-06-2010 09:08

how to get players IP?
 
Ok so it is me again.

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

Thank you.

Keeper 01-06-2010 10:18

Re: how to get players IP?
 
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

DigiSoft 01-06-2010 10:27

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

Keeper 01-06-2010 10:35

Re: how to get players IP?
 
it would be:
Code:

const char *ip = nci->GetAddress();

DigiSoft 01-06-2010 10:51

Re: how to get players IP?
 
Oh thank you I also forgot to include inetchannelinfo.h.

Now it works.

Thank you again.

DigiSoft 01-06-2010 11:12

Re: how to get players IP?
 
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 ?

Keeper 01-06-2010 11:31

Re: how to get players IP?
 
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();                     
}


DigiSoft 01-06-2010 11:44

Re: how to get players IP?
 
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?

Keeper 01-06-2010 11:46

Re: how to get players IP?
 
This would be an easy place to debug. Do you have it set up for debugging?

DigiSoft 01-06-2010 11:51

Re: how to get players IP?
 
Ahhhh I am little noob to debugging. :D

Arghhhh I really don't know why it crashes.

It crashes on netinfo->GetAddress()


All times are GMT -4. The time now is 09:17.

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