Difference between revisions of "TTeam.OnJoin"
(new page) |
m (Export fix (1.6.6b)) |
||
(5 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== | ||
− | Event property called when | + | Event property called when a player tries to change team |
<br> | <br> | ||
==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 22: | Line 22: | ||
begin | begin | ||
− | // assign | + | // assign OnJoinTeam handler |
− | Game. | + | Game.Teams[2].OnJoin := @MyOnJoinTeamHandler; |
// ... | // ... | ||
// unassign | // unassign | ||
− | Game. | + | 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;