Difference between revisions of "TPlayers.Add"

From Soldat Community Wiki
Jump to: navigation, search
(Example)
Line 3: Line 3:
 
   Result: Active instance of bot
 
   Result: Active instance of bot
  
Adds a new bot to game basing on configuration from [[TNewPlayer]].
+
Adds a new bot to game basing on configuration from [[TNewPlayer]].
'''Don't forget to free TNewPlayer instance after using it!'''
+
  '''Don't forget to free TNewPlayer instance after using it!'''
  
 
===Example===
 
===Example===

Revision as of 23:50, 24 June 2013

function Add(NewPlayer: TNewPlayer): TActivePlayer
 NewPlayer: An instance of TNewPlayer serving as configuration object for the bot
 Result: Active instance of bot
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.Name := 'Test bot!';
      NewPlayer.Team := 1; // important!
      NewPlayer.PantsColor := $FFFFFFFF;
      NewPlayer.SkinColor := $FFFFFFFF;
      Players.Add(Player);
    finally
      NewPlayer.Free; // important!
    end;
  end;