TPlayers.GetByIP

From Soldat Community Wiki
Jump to: navigation, search
function GetByIP(IP: string): TActivePlayer
 IP: IP to be searched for

Description

Returns a TActivePlayer whose IP is equal to the searched one.
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 an IP among players and kicks a player if he was found.

const
  BADGUY = '192.168.1.1';
var 
  p: TActivePlayer;
begin
  p := Players.GetByIP(BADGUY);
  if p <> Nil then // important
    p.Kick();
end;