NWN2 Server Detection

Hi All,

Is there any way to detect if the NWN2 Server has been started?

I had a pseudo method that worked for a while, but am now having problems due to being unable to determine if the host is the first entering player or not.

So, bottom line, is there an integer set somewhere that we can test against to see if the game is running via the NWN2 Server or the “normal” MP start method?

NWNXGetInt("NWNX", "INSTALLED", "", 0) will return TRUE if the nwn2server process has been started by nwnx4. However with this method, you won’t be able to detect if nwn2server has been started in standalone without nwnx4.

Also, I don’t know what is the IP address of the host when the server is started with MP start (string GetPCIPAddress(object oPlayer)). Maybe there’s a special value ?

1 Like

@CromFr

Thanks for the info. :+1: I was hoping there may have been a more straightforward var check I could check without requiring third party software.

For now, I am simply adding a check further down the line of a player entering the module. It’s a couple of clicks later, but will have to do if there’s no easy way of determining this with the basic functions.

After some testing, when the server is started from the game client (MP Start method), GetPCIPAddress(oPC) returns "127.0.0.1" which is an address only accessible from the same machine as the server.

If I start the server via nwn2server.exe, the server can’t be reach using 127.0.0.1 (which is a bit surprising. There may be a way to allow connections from 127.0.0.1 with some nwn2server config), and instead the server needs to be reached with the IP of the server machine on its LAN network (the address given by your router).

So you could define this function:

int GetServerStartedWithMPStart(){
	object oPC = GetFirstPC();
	while(GetIsObjectValid(oPC))
	{
		if(GetPCIPAddress(oPC) == "127.0.0.1")
			return TRUE;
		oPC = GetNextPC();
	}
	return FALSE;
}

One caveat however: if another player enters the server before the player hosting the server has selected his character, GetServerStartedWithMPStart will return FALSE

1 Like

@CromFr

That is similar to my workaround I am using at the moment. (Which I had to comment out due to needing a GUI response for early arriving players other than the host.)

And that is the exact issue I am trying to circumvent … it is to try to warn players about certain situations. In the end, I opted to giving fast entering players (before the host finished loading) the priority GUI response over the late entering Host starting the wrong way. At least the host eventually gets the warning, but on the back end of another GUI that also warns about waiting for the host.

I hope that made sense - I think if anybody understood that, it sounds like you would, as you appear to have grasped my requirements. :sweat_smile:

BACKGROUND: I was basically checking if the players entering were players other than the host and basically giving them a GUI to say “wait” until the host was present. At the same time, I needed a check to see if the Host had started the server (by mistake) rather than use the multiplayer start option required for the campaign.

The problem is, if the host starts first (and actually gets into the game), I can check if they have started the correct way by using a similar function to you. However, if the other player gets in first, then they also get the same warning even if the Host started correctly because they are not the host, the pseudo method we are using to check if the host started the game correctly.

I feel like there should be a variable set somewhere when the specific NWN2 Server is started, if only we could find it.