Difference between revisions of "TGame.OnRequest"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
m
Line 6: Line 6:
  
 
==Description==
 
==Description==
Event property called when a player joins the server.
+
Event property called when a player connects with a server in order to join.
 
<br>  
 
<br>  
 +
 +
{| class="wikitable"
 +
|-
 +
! State Value !! Description
 +
|-
 +
| 1 || OK
 +
|-
 +
| 2 || Wrong Soldat version
 +
|-
 +
| 3 || Wrong password
 +
|-
 +
| 4 || Banned
 +
|-
 +
| 5 || Server full
 +
|-
 +
| 6 || Duplicate IP
 +
|-
 +
|}
  
 
==Example==
 
==Example==
 +
Example allows players to join even if they enter wrong password
 
<syntaxhighlight lang="pascal">
 
<syntaxhighlight lang="pascal">
  procedure SpecOnJoin(Player: TActivePlayer; Team: TTeam);
+
  function MyOnRequestHandler(Ip: string; Port: Word; State: Byte; Forwarded: Boolean; Password: string): Integer;
 
  begin
 
  begin
   Player.Team := 5;
+
   if (State = 3) then
 +
    State := 1;
 +
  Result := State;
 
  end;
 
  end;
  
Line 19: Line 40:
  
 
  begin
 
  begin
   // assign OnJoin handler
+
   // assign OnRequest handler
   Game.OnJoin := @SpecOnJoin;
+
   Game.OnRequest := @MyOnRequestHandler;
  
 
   // ...
 
   // ...
  
 
   // unassign
 
   // unassign
   Game.OnJoin := nil;
+
   Game.OnRequest := nil;
 
  end;
 
  end;
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:TGame]]
 
[[Category:TGame]]

Revision as of 13:47, 26 July 2013

property OnRequest
 Access mode: RW
 Event handler type: TOnRequestEvent
 Event handler declaration: 
   function (Ip: string; Port: Word; State: Byte; Forwarded: Boolean; Password: string): Integer;

Description

Event property called when a player connects with a server in order to join.

State Value Description
1 OK
2 Wrong Soldat version
3 Wrong password
4 Banned
5 Server full
6 Duplicate IP

Example

Example allows players to join even if they enter wrong password

 function MyOnRequestHandler(Ip: string; Port: Word; State: Byte; Forwarded: Boolean; Password: string): Integer;
 begin
   if (State = 3) then
     State := 1;
   Result := State;
 end;

 // ...

 begin
   // assign OnRequest handler
   Game.OnRequest := @MyOnRequestHandler;

   // ...

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