Difference between revisions of "TGame.OnLeave"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
  '''''property OnLeave'''''
 
  '''''property OnLeave'''''
 
   Access mode: RW
 
   Access mode: RW
 +
  Event handler type: [[TOnLeaveGameEvent]]
 
   Event handler declaration: procedure (Player: [[TActivePlayer]]; Kicked: Boolean);
 
   Event handler declaration: procedure (Player: [[TActivePlayer]]; Kicked: Boolean);
  
 
==Description==
 
==Description==
Event property called when a player leaves the server or gets kicked/banned.
+
Event property called when any player leaves the server or gets kicked/banned.
<br>  
+
<br>
 +
{{note|Inside this event handler, player count is as if the player was still in game and all Player.Active is TRUE}}
  
 
==Example==
 
==Example==
Line 14: Line 16:
 
     WriteLn(Player.Name + ' has been kicked!')
 
     WriteLn(Player.Name + ' has been kicked!')
 
   else
 
   else
     WriteLn(Player.Name + ' has left the game in peace')
+
     WriteLn(Player.Name + ' has left the game in peace');
 
  end;
 
  end;
  
Line 30: Line 32:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
[[Category:TGame]]
+
[[Category:TGame]][[Category:Events]]

Latest revision as of 11:33, 10 September 2016

property OnLeave
 Access mode: RW
 Event handler type: TOnLeaveGameEvent
 Event handler declaration: procedure (Player: TActivePlayer; Kicked: Boolean);

Description

Event property called when any player leaves the server or gets kicked/banned.

Note: Inside this event handler, player count is as if the player was still in game and all Player.Active is TRUE

Example

 procedure MyOnLeaveHandler(Player: TActivePlayer; Kicked: Boolean);
 begin
   if Kicked then
     WriteLn(Player.Name + ' has been kicked!')
   else
     WriteLn(Player.Name + ' has left the game in peace');
 end;

 // ...

 begin
   // assign OnLeave handler
   Game.OnLeave := @MyOnLeaveHandler;

   // ...

   // unassign
   Game.OnLeave := nil;
 end;