Difference between revisions of "TTeam.OnJoin"
m (→Description) |
m (Export fix (1.6.6b)) |
||
(2 intermediate revisions by 2 users 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.Tell('Sorry, you can''t join Bravo Team'); | |
− | |||
− | |||
end; | end; | ||
Line 23: | Line 23: | ||
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]] |
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;