TPlayers.GetByName

From Soldat Community Wiki
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 (or to player if found).

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