Author Topic: How to tell SP vs MP via script ? Way to determine server's IP ?  (Read 356 times)

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
How to tell SP vs MP via script ? Way to determine server's IP ?
« on: November 11, 2011, 07:57:10 am »


               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.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to tell SP vs MP via script ? Way to determine server's IP ?
« Reply #1 on: November 11, 2011, 10:30:00 am »


               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.    
               
               

               
            

Legacy_OldMansBeard

  • Full Member
  • ***
  • Posts: 245
  • Karma: +0/-0
How to tell SP vs MP via script ? Way to determine server's IP ?
« Reply #2 on: November 11, 2011, 11:55:03 am »


               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.
               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
How to tell SP vs MP via script ? Way to determine server's IP ?
« Reply #3 on: November 11, 2011, 05:33:22 pm »


               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. :-)