Skip to content

From script, can you tell if mod is single player or running on server?

FinalStandFinalStand Member Posts: 87
edited February 2018 in Builders - Scripting
From my scripts it would be helpful if I could determine if the module is running as single player or if it's multiplayer/server. Is there any way to determine that ?

If not with native script call, could this be done though 2da files? Maybe have 2da file on server? For single player it won't exist, but multiplayer you could have 'server, 1' or something? Does NWN let you have custom .2da files?


  • SherincallSherincall Member Posts: 387
    From nwscript.nss:

    // 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);

    So, try:
    int IsSinlgePlayer() { return GetPCPublicCDKey(GetFirstPC(), FALSE) == ""; }
  • FinalStandFinalStand Member Posts: 87
    I like it! Nice and simple.
Sign In or Register to comment.