Has GetPCPublicCDKey/GetPCPlayerName functionalities Changed?

I use this function to help ID players … However, it appears to return a blank string and not an ID now.

Any info?

And GetPCPlayerName?

If you just need to identify the same character you can now use UUID which is stored to save games and even the BIC on export or migration to new modules. GetObjectUUID(object) - NWN Lexicon

1 Like


I am trying to differentiate between players, including who is the host. I need unique ID for each player.

I’ll take a look at that new function then. Thanks!

Let me know if you don’t think that will help. :wink:

PS: This is a pain in the butt! :hushed:


OK, I checked out the return in the ID function, and it’s quite a large string.

Do you know how many characters EE allows for a creature tag (and variable holder names)?

EG: Are we restricted to 32 characters?

If so, can we rely in the first few characters (or end few) to be unique enough for the unique ID?

Local variables can be long. Tags generally are safest at 32 characters.

The UUID is useful if you do more than one module or support MP (and just mark the first player as the host usually).

You also could store sql on the player BIC itself, or on the module (save game) and use UUID as needed.

Maybe easier to discuss on Discord. It all does depend on what you need to do.

Thanks for responding quickly again.

OK, I think I can still work with something like this for now then …

    // string PlayerID = GetPCPublicCDKey(oPlayer, TRUE);

    string PlayerID = GetStringLeft(GetObjectUUID(oPlayer), 10);

I think my original host function still works, but uses the host’s PC object rather than the player name now.

I’d not change the UUID length since, well, then it’s not unique. There are other means and ways, maybe just setting the time and date. Can use sql to get it.

Really depends if things are going in sql, variables or whatnot.


I was afraid you were going to say that … But … I only really need a random identifier for each potential player, and I would have thought the first ten characters of that ID were sufficiently random and unique to suffice … or no?

PS: The game is “closed” as a coop game only - not a PW.

Isn’t the character name unique enough? Not sure why you need to cap it to 10 characters though.


It should be, but I did not want to risk having two players join the same game with the same name.

I only limited it to ten because it allows my own prefix to be a reasonable length. (I am also trying to avoid rewriting as much as possible.)

I did also consider just allocating each player their own number (random or incremented according to how many already recorded on the module). That would also work I guess.

Maybe I should look at my options and consider a different approach – I was just trying to avoid too much rewriting - even if it could do with it in places. :wink:

I’m all for not rewriting! If the variable is used in other code 32 characters may not be too bad. It’s not a very very long string at least. Local variables will be fine with it. If you use the campaign dB functions I can suggest alternatives.

1 Like


Me too … even if not as efficient and as good as I could do now. :wink:

I think I will allow the full ID for variable holder names, and just look at potentially limiting the ID for a creature tag ref then.

Just to confirm, you think this would be OK as a variable holder … pseudo example code …


As I say, I’ll have to restrict it a bit when used as a TAG, as I also use the unique ID for a creature TAG associated with the player.

GetPCPublicCDKey() should work the same as in NWN Diamond, make sure you have the second parameter set to TRUE when testing in singleplayer.


It always is/was set to TRUE … But the return was always “” in EE. (Steam version anyway.)

See example of where I changed above … again here …

    // string PlayerID = GetPCPublicCDKey(oPlayer, TRUE);

    string PlayerID = GetStringLeft(GetObjectUUID(oPlayer), 10);

When running the game through Steam, have you clicked on Multiplayer in the menu yet? I think it only grabs your cdkey at that point

1 Like

Oh no! … seriously? I am going to have to test that now then, as I cannot rely on a player who plays SP only to have generated their cdkey by the time they start the game.

Argh! You are absolutely correct - I never knew this!

Now I need to reconsider this again, as I can supply my own ref for SP, allowing the standard function to work as normal then when players play coop MP.

Thanks Daz!

Now, I just need to do this … Although, I am going to run it through a GetIsSinglePlayer to force SPGAME usage too. … Although, I’m not sure NWN1 has that function check … :thinking:

OK … This … And I’ll retrieve the string myself. (Set on player enter mod.)

string sPlayerID = GetLocalString(oPlayer, "PLAYERID");

    if(sPlayerID == "")
        string sPlayerID = GetPCPublicCDKey(oPlayer, TRUE);
        if(sPlayerID == ""){sPlayerID = "SPGAME";}
        SetLocalString(oPlayer, "PLAYERID", sPlayerID);

I had always tested with a copy where I had played MP previously, and so when I was testing SP game, the key was present from the start!

That is UUID use is fine for variables - they can be pretty large names for them and run much quicker now.

For SP/MP it’s difficult since really SP is just “MP without anyone able to join” so a lot of the game acts the same way. You could I guess just have SP mode on, and then if a second player joins - well, it must be MP.

1 Like


Knowing how the Public CD Key is now set, that’s pretty much what I do now.

The above On Mod Enter checks if a valid key already exists (whether the player has ever started a MP game or not) and then uses that (or a default “SPGAME” if absent).

Then, on the start of a MP game, the CD key will be present and always used instead.

I only put the check in, just in case, a player starts a SP game, (prior a MP one) and has SPGAME setup for the SP game, and then also starts a MP game (generating a CD KEY), which I want to ignore if the game has already been using the SPGAME ref. (i.e. Playing SP and MP at the same time.)

I hope that makes sense. :slight_smile: