Difference between revisions of "TGame.OnLeave"

From Soldat Community Wiki
Jump to: navigation, search
m (Example)
m (Added missing semicolon)
Line 15: Line 15:
 
     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;
  

Revision as of 13:54, 29 July 2013

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.

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;