Difference between revisions of "TPlayers.Add"

From Soldat Community Wiki
Jump to: navigation, search
m
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  ''function Add(NewPlayer: [[TNewPlayer]]): [[TActivePlayer]]''
+
  '''''function Add(NewPlayer: [[TNewPlayer]], JoinType: [[TJoinType]]): [[TActivePlayer]]'''''
 
   NewPlayer: An instance of TNewPlayer serving as configuration object for the bot
 
   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
 
   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!'''
  
Adds a new bot to game basing on configuration from [[TNewPlayer]].
+
== Example ==
  '''Don't forget to free TNewPlayer instance after using it!'''
 
 
 
===Example===
 
 
<syntaxhighlight lang="pascal">
 
<syntaxhighlight lang="pascal">
 
   var
 
   var
Line 13: Line 14:
 
     NewPlayer := TNewPlayer.Create;
 
     NewPlayer := TNewPlayer.Create;
 
     try
 
     try
      NewPlayer.Name := 'Test bot!'
 
 
       NewPlayer.Name := 'Test bot!';
 
       NewPlayer.Name := 'Test bot!';
 
       NewPlayer.Team := 1; // important!
 
       NewPlayer.Team := 1; // important!
 
       NewPlayer.PantsColor := $FFFFFFFF;
 
       NewPlayer.PantsColor := $FFFFFFFF;
 
       NewPlayer.SkinColor := $FFFFFFFF;
 
       NewPlayer.SkinColor := $FFFFFFFF;
       Players.Add(Player);
+
       Players.Add(NewPlayer, TJoinNormal);
 
     finally
 
     finally
 
       NewPlayer.Free; // important!
 
       NewPlayer.Free; // important!
Line 24: Line 24:
 
   end;
 
   end;
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
[[Category:TPlayers]]

Latest revision as of 12:08, 9 September 2016

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;