Difference between revisions of "TTeam.OnJoin"

From Soldat Community Wiki
Jump to: navigation, search
m (Description)
m (Example)
Line 12: Line 12:
 
  procedure MyOnJoinTeamHandler(Player: TActivePlayer; Team: TTeam);
 
  procedure MyOnJoinTeamHandler(Player: TActivePlayer; Team: TTeam);
 
  begin
 
  begin
   if Team.ID = 2 then
+
   Player.Team := 1;
  begin
+
  Player.Tell('Sorry, you can''t join Bravo Team');
    Player.Team := 1;
 
    Player.Tell('Sorry, you can''t join Bravo Team');
 
  end;
 
 
  end;
 
  end;
  
Line 23: Line 20:
 
  begin
 
  begin
 
   // assign OnJoinTeam handler
 
   // assign OnJoinTeam handler
   Game.Teams[1].OnJoin := @MyOnJoinTeamHandler;
+
   Game.Teams[2].OnJoin := @MyOnJoinTeamHandler;
  
 
   // ...
 
   // ...
  
 
   // unassign
 
   // unassign
   Game.Teams[1].OnJoin := nil;
+
   Game.Teams[2].OnJoin := nil;
 
  end;
 
  end;
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:TTeam]][[Category:Events]]
 
[[Category:TTeam]][[Category:Events]]

Revision as of 13:52, 29 July 2013

property OnJoin
 Access mode: RW
 Event handler type: TOnJoinTeamEvent
 Event handler declaration: procedure (Player: TPlayer; Team: TTeam);

Description

Event property called when a player tries to change team

Example

 procedure MyOnJoinTeamHandler(Player: TActivePlayer; Team: TTeam);
 begin
   Player.Team := 1;
   Player.Tell('Sorry, you can''t join Bravo Team');
 end;

 // ...

 begin
   // assign OnJoinTeam handler
   Game.Teams[2].OnJoin := @MyOnJoinTeamHandler;

   // ...

   // unassign
   Game.Teams[2].OnJoin := nil;
 end;