TPlayers.GetByName

From Soldat Community Wiki
Revision as of 07:38, 25 July 2013 by Mighty (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
function GetByName(Name: string): TActivePlayer
 Name: name to be searched for

Description

Returns a TActivePlayer whose name is equal to the searched one. Case sensitive.
Returns Nil if a player was not found.
Warning: Trying to work on a "Nil-player" (result of the function when a player was not found) might throw exceptions or be critical. Remember to make sure a player was found before you try to do anything with him.

Example

Example is trying to find a nickname "~ Mighty" among players and displays proper information to all players.

var 
  p: TActivePlayer;
begin
  p := Players.GetByName('~ Mighty');
  if p = Nil then // important
    Players.Tell('Mighty is not playing here atm ;(')
  else
    Players.Tell('Hello Mighty!');
end;