Difference between revisions of "TPlayers.GetByName"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
(No difference)

Revision as of 06:38, 25 July 2013

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;