Difference between revisions of "TTeam.OnJoin"
m (→Description) |
m (→Example) |
||
Line 12: | Line 12: | ||
procedure MyOnJoinTeamHandler(Player: TActivePlayer; Team: TTeam); | procedure MyOnJoinTeamHandler(Player: TActivePlayer; Team: TTeam); | ||
begin | begin | ||
− | + | Player.Team := 1; | |
− | + | Player.Tell('Sorry, you can''t join Bravo Team'); | |
− | |||
− | |||
− | |||
end; | end; | ||
Line 23: | Line 20: | ||
begin | begin | ||
// assign OnJoinTeam handler | // assign OnJoinTeam handler | ||
− | Game.Teams[ | + | Game.Teams[2].OnJoin := @MyOnJoinTeamHandler; |
// ... | // ... | ||
// unassign | // unassign | ||
− | Game.Teams[ | + | 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;