TPlayers.Add

From Soldat Community Wiki
Revision as of 20:50, 23 June 2016 by Falcon (talk | contribs) (Added JoinType parameter)
Jump to: navigation, search
function Add(NewPlayer: TNewPlayer, JoinType: TJoinType): TActivePlayer
 NewPlayer: An instance of TNewPlayer serving as configuration object for the bot
 JoinType: Enum (TJoinNormal, TJoinSilent)�. Silent join will not generate message in console
 Result: Active instance of bot

Description

Adds a new bot to game basing on configuration from TNewPlayer. Don't forget to free TNewPlayer instance after using it!

Example

  var
    NewPlayer: TNewPlayer;
  begin
    NewPlayer := TNewPlayer.Create;
    try
      NewPlayer.Name := 'Test bot!';
      NewPlayer.Team := 1; // important!
      NewPlayer.PantsColor := $FFFFFFFF;
      NewPlayer.SkinColor := $FFFFFFFF;
      Players.Add(NewPlayer, TJoinNormal);
    finally
      NewPlayer.Free; // important!
    end;
  end;