GetPCPublicCDKey(object)

Retrieves the public version of the PC's CD key.

string GetPCPublicCDKey(
    object oPlayer
);

Parameters

oPlayer

The player whose CD key to retrieve.


Description

Returns the public version of the CD Key that oPlayer uses when playing multiplayer games. In single player games, this function returns an empty string (""). The public CD key is 8 characters long and is not the CD key used to install NWN or an expansion.



Remarks

Most likely used with functions such as BootPC() to combat mischievious players from causing havok on persistant worlds.

Note that if you are relying on the return of this function within a module and your module is intended for both multi- and single- player play, single player mode always causes this function to return an empty string.


Known Bugs

Not a bug, but a caveat

OnClientLeave, the PC object (GetExitingObject) is still valid, but the player object (i.e. the human being logged into the server) is not. This means that there are a few things you can't do OnClientLeave. Namely, the GetPCPlayerName, GetPCIPAddress, and GetPCPublicCDKey will not work, since the player is no longer around to get that information from. This can be worked around by storing them as local strings on the PC, for instance OnClientEnter. See workaround below.


Version

1.61

Example

//Workaround for the caveat above

void main()
{
object oPC=GetEnteringObject();
string sPlayerName=GetPCPlayerName(oPC);
string sIP=GetPCIPAddress(oPC);
string sKey=GetPCPublicCDKey(oPC);
SetLocalString(oPC, "player_name", sPlayerName);
SetLocalString(oPC, "player_ip", sIP);
SetLocalString(oPC, "player_cdkey", sKey);
}

See Also

functions: BootPC
categories: PC Only Functions


 author: Sarev0k, editor: Lilac Soul, additional contributor(s): Steve Moseley, Lilac Soul
 Send comments on this topic.