You can also share the same MySQL database and pass commands through it, just make an table to send commands (with the fields ID, COMMAND [primary key, auto-increment], RESPONSE [varchar, default: NULL], EXECUTED [int], SERVER [int], TIME [int]) that will be used from the source server to the target server.
I don't know how can I explain it, because I really don't know anything about pawn script, but it is very simple... all you need is convert the php codes that I will post here to Pawn.
here is the function who sends an command to Server Y and wait until get an response:
PHP код:
<?php
$command = "msgtoall Hello there, I am Server X!";
$waitTime = 0; //Seconds;
$time = time();
@mysql_query("INSERT INTO commands(COMMAND, SERVER, TIME) VALUES('{$command}', 2, {$time})");
while(1) {
$query = @mysql_query("SELECT * FROM commands WHERE COMMAND='{$str}' AND TIME={$time} ORDER BY TIME DESC LIMIT 0,1");
$resp = @mysql_fetch_array($query);
$resp_exec = (bool)$resp["EXECUTED"];
if($resp_exec) { // If the command were executed successfuly
$return = $resp["RESPONSE"];
break;
} else if($waitTime >= 5) { //If the request got no response for 5 seconds, stop the execution and return boolean false.
$return = false;
break;
}
++$waitTime;
sleep(1);
}
if(!$return) {
SendAdminMessage("The command request to Server Y don't had any response."); //The function SendAdminMessage does not exists, I know T_T it is only a example.
}
?>
and in the Server Y game mode, you will set a timer to verify if "commands" table have rows with "EXECUTED" field containing value "0".
Код:
SELECT * FROM commands WHERE EXECUTED = 0
then you will fetch this query data, verifying the "COMMAND" field value.
PHP код:
<?php
$query = @mysql_query("SELECT * FROM commands WHERE EXECUTED = 0 AND SERVER = 2"); //Server 2 = Server Y, Server 1 = Server X. In Server X just change SERVER = 2 to SERVER = 1.
while($r = @mysql_fetch_array($query)) {
$id = $r["ID"];
$command = $r["COMMAND"];
$command = explode(" ",$command);
$cmd = $command[0];
unset($command[0]);
$response = 0;
switch($cmd) {
case "msgtoall":
$message = implode(" ", $command);
if(SendClientMessageToAll(0xFF0000, $message)) { //Pawn function
$response = 1;
}
break;
case "msgtoplayer":
$playerid = $command[1];
unset($command[1]);
$message = implode(" ", $command);
if(SendClientMessage($playerid, 0xFF0000, $message)) {
$response = 1;
}
break;
/** other cases **/
}
//After execute it, update the command row.
@mysql_query("UPDATE commands SET EXECUTED = 1, RESPONSE = {$response} WHERE ID = {$id}");
}
?>
You need these scripts in both servers, so you can send commands from Server X to Y and from Y to X, just changing the "SERVER" field in the query "INSERT".
It's logical that have security stuff missing, but I hope that you will understand the logic behind it.
I don't know about lag, I use this method to make an connection between my server and my website without lag, but this method can also works between two servers without lag as well.