Difference between revisions of "TTeam.OnJoin"
m (→Example) |
m (Export fix (1.6.6b)) |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
Access mode: RW | Access mode: RW | ||
Event handler type: [[TOnJoinTeamEvent]] | Event handler type: [[TOnJoinTeamEvent]] | ||
− | Event handler declaration: procedure (Player: [[ | + | Event handler declaration: procedure (Player: [[TActivePlayer]]; Team: [[TTeam]]); |
==Description== | ==Description== | ||
Line 10: | Line 10: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="pascal"> | <syntaxhighlight lang="pascal"> | ||
− | procedure MyOnJoinTeamHandler( | + | 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'); |
Latest revision as of 16:25, 9 September 2013
property OnJoin Access mode: RW Event handler type: TOnJoinTeamEvent Event handler declaration: procedure (Player: TActivePlayer; 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;