OnRequestGame

From Soldat Community Wiki
Jump to: navigation, search

From the Scripting Manual

 function OnRequestGame(IP: string; State: integer): integer;
 
 Parameter Info:
  IP (String): IP Address of the player requesting game.
  State (integer): Current state of the player who requested. See below for values.
 
 State Values:
  OK = 1;
  WRONG_VERSION = 2;
  WRONG_PASSWORD = 3;
  BANNED_IP = 4;
  SERVER_FULL = 5;
  DUPLICATE_IP = 6;
 
 Description:
  This function will be called every time a player tries to join your server.
  OnRequestGame can be used as an intercept to change the state of the reply that is sent to the Player, so if you modify the State variable, the new State will be sent to the player. With this, you will be able to have your own limitations to the server such as a "Reserved Slot" list, and much more. See the example below for how to code a "Reserved" list.

Examples

Reserved IP list

This example will show you how to code a Reserved IP list:

function OnRequestGame(IP: string;State: integer):integer;
var
VIPList: TStringArray;
i: integer;
begin
 VIPList := split(ReadFile('viplist.txt'),chr(13)+chr(10)); // Open viplist.txt and split into array
 for i := 0 to ArrayHigh(VIPList) do
  if (IP = VIPList[i]) And (State = 1) or (State = 5) then begin
// If player IP is in list, and they arent banned.
    State := 1; // OK
    break; //End looping
  end;
 result := State; // Return new state
end;

Note that the function Split no longer exists. You would need to create the XSplit function and use that instead.

External Links