Aller au contenu

Photo

How to tell SP vs MP via script ? Way to determine server's IP ?


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
MrZork

MrZork
  • Members
  • 942 messages
Probably a dumb question, but I would like to know if there is a fairly straightforward way to tell from inside a given module's scipts whether the current game is being played in single-player mode or a multiplayer mode? To be clear, it's easy to tell how many PCs are playing; but that isn't what I am interested in. I want to know if there is a way to tell in which mode the game is running. For example, I'd like some way to know if a given PC got there by just hitting load game  (or new game) or if he got there by joining a multiplayer game via LAN or Internet.

Also, sort of a related question, is there a way for a script to get the server's IP? I know there is a call that's supposed to return the player's IP as a string, but is there something analogous for the server on which the module is running?

Both questions are in the context of vanilla NWN 1.69, no way to tell if NWNX or any SQL API calls would be available.

Sorry of the question is poorly defined. I think it should be an easy thing to do, but I may not know enough about the server to describe this properly.

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
For single player vs multi.

// Get the public part of the CD Key that oPlayer used when logging in.
// - nSinglePlayerCDKey: If set to TRUE, the player's public CD Key will
//   be returned when the player is playing in single player mode
//   (otherwise returns an empty string in single player mode).
string GetPCPublicCDKey(object oPlayer, int nSinglePlayerCDKey=FALSE)


As far as vanilla NWN goes, I do not think it even knows its own IP address.  The server screen does report its local IP, but not it's external IP.   For help on that one you may need to wait for one of the NWNx experts to reply.    

#3
OldMansBeard

OldMansBeard
  • Members
  • 152 messages
If it helps:
GetPCIPAddress() returns blank in single player, otherwise it returns non-blank. So if a GetStringLength()>0 you're on multiplayer. If the player has logged on from the same machine as the server, it returns "127.0.0.1" otherwise an external IP.

#4
MrZork

MrZork
  • Members
  • 942 messages
Thanks to both of you. I had stumbled across GetPCIPAddress() returning a blank string, but hadn't tested it in MP and thought I was just doing something wrong. It looks like I can use that behavior to find out just what I need to know. :-)