Difference between revisions of "TTeam.OnJoin"

From Soldat Community Wiki
Jump to: navigation, search
m (Example)
(Example)
Line 10: Line 10:
 
==Example==
 
==Example==
 
<syntaxhighlight lang="pascal">
 
<syntaxhighlight lang="pascal">
  procedure MyOnJoinTeamHandler(Player: TActivePlayer; Team: TTeam);
+
  procedure MyOnJoinTeamHandler(temp: TPlayer; Team: TTeam);
 +
var
 +
  Player: TActivePlayer;
 
  begin
 
  begin
 +
  Player := TActivePlayer(temp); // this is important! Without that you can't use many TActivePlayer members!
 
   Player.Team := 1;
 
   Player.Team := 1;
 
   Player.Tell('Sorry, you can''t join Bravo Team');
 
   Player.Tell('Sorry, you can''t join Bravo Team');

Revision as of 22:23, 4 August 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(temp: TPlayer; Team: TTeam);
 var 
   Player: TActivePlayer;
 begin
   Player := TActivePlayer(temp); // this is important! Without that you can't use many TActivePlayer members!
   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;