Difference between revisions of "GetPlayerByUsername"

From King Arthur's Gold Wiki
Jump to: navigation, search
(Created page with "<onlyinclude> Returns a reference to the CPlayer that has the given username, if one currently exists, otherwise it returns null. </onlyinclude> <syntaxhighlight lang="cpp"> ...")
 
 
Line 9: Line 9:
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
 
CPlayer@ player = getPlayerByUsername(username);
 
CPlayer@ player = getPlayerByUsername(username);
 +
if (player !is null)
 +
{
 +
  // Do stuff with the player
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Scripting]]
 
[[Category:Scripting]]
 
[[Category:Global Functions]]
 
[[Category:Global Functions]]

Latest revision as of 20:22, 27 August 2012

Returns a reference to the CPlayer that has the given username, if one currently exists, otherwise it returns null.

CPlayer@ getPlayerByUsername( string name )

Usage example:

CPlayer@ player = getPlayerByUsername(username);
if (player !is null)
{
  // Do stuff with the player
}