GetFirstPC

From NWN Lexicon
Revision as of 17:48, 6 July 2019 by Shadguy (talk | contribs) (Added note about Dungeon Masters)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



GetFirstPC()

Obtains the first PC

Description

Returns the first PC in the PC list in order to cycle through all PCs with GetNextPC().



Remarks

Useful for debugging purposes. If only one person is testing the module you can use SendMessageToPC(GetFirstPC(), "Something Happened") and the first (and only) PC will see that message.


If you are building for multiplayer, be aware of uses of this function. You could be performing tasks on a player that was not your intended target.


Note that Dungeon Masters are included in the list of Players checked by this function and GetNextPC().

Version

1.22

Example

// This function cycles through all PCs and counts how many there are
void main()
{
   int nPCs = 0;
   object oPC = GetFirstPC();
   while (GetIsObjectValid(oPC) == TRUE)
   {
      nPCs = nPCs+1; // nPCs++;
      oPC = GetNextPC();
   }
}

See Also

functions: 

GetNextPC



 author: Tom Cassiotis, editor: Charles Feduke, Mistress