• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS multiple server problems

Diazapam

!ROFLMAO!
Joined
Jul 29, 2009
Messages
1,411
Reaction score
9
Location
$_GET['Country']
I'm having some tests using the TFS login server (Thanks elf :peace:)
As i'm setting it up I'm running into several problems.

Client info:
OS: Ubuntu 9.10 (fully updated)
TFS login server version: 0.2
TFS version: 0.4 (rev 3600)
Tibia version: 8.54


I've changed some things, I think to be able to make the servers globalsave seperatly they need 2 different databases, So its time to try to get that running :)


First problem:
Keeps saying that there is something wrong with the login/pass while its not.
Solution to the first problem.

Second problem:
The TFS login server only works for 8.50 clients and should be updated to 8.54, is there any way I can do that myself?
I have the source and know how to compile I just don't know what to change.
Solution to the second problem

Third problem:
Players from the outside can't connect to the server. They do see the character list though.
Ports are forwarded and opened.
Error: Invalid server address. (10049)
Solution to the third problem

Fourth problem:
The servers.xml should support names and not just ip's.
Since I now had to set my server ip i'd rather set a no-ip.org to make server changes easier.
This will most likely require a source edit of the login server, any ideas please tell me.


Fifth problem:
The site doesn't work perfectly with the login server.
When one of the servers goes offline it just says the whole server is offline which it ain't.
Solution to the fifth problem

Sixth problem:
The whoisonline page of the server should have an entry page which shows amount of players on each server together with if the server is offline or offline.
Solution to the sixth problem

Seventh problem:
To make the globalsaves (shutdown like in rl tibia) and mysql dumps perform seperatly (so 1 goes down at 05:00PM and the other one at 06:00PM (example)) there should be 2 databases instead of 1.
To make this possible I'm afraid alot has to be changed in the configs.
I'm also looking for the possibility to do this with --enable-login-server instead of using a seperate login server like now.
 
Last edited:
I think its fixed, its looking as this now:

Servers.xml for login server:
Lua:
<servers>
        <server id="0" name="Server nr 0" address="192.168.X.X" port="7470"/>
        <server id="1" name="Server nr 1" address="192.168.X.X" port="7471"/>
</servers>
7470 is the game port of the first server
7471 is the game port of the second server

The servers are set as this:

Server1:
Lua:
Worldid ="0"
loginport ="7370"
gameport ="7470"
loginOnlyWithLoginServer = false
Server2:
Lua:
Worldid ="1"
loginport ="7371"
gameport ="7471"
loginOnlyWithLoginServer = false

The only error I get now is that my client should be 8.54, the login server only works with 8.50.
 
Last edited:
Ok well the next problem is also fixed.

I've opened the source folder and let notepad++ find the string 8.54.
I've came out in the file resources.h

In there I saw the following:
Code:
#define STATUS_SERVER_NAME "The Forgotten Login Server"
#define STATUS_SERVER_VERSION "0.2"
#define STATUS_SERVER_CODENAME "Cruel Coconut"
#define STATUS_SERVER_PROTOCOL "8.50"
#define CLIENT_VERSION_MIN 850
#define CLIENT_VERSION_MAX 850
#define CLIENT_VERSION_STRING "Only clients with protocol 8.50 allowed!"
I changed that to:
Code:
#define STATUS_SERVER_NAME "The Forgotten Login Server"
#define STATUS_SERVER_VERSION "0.2.854"
#define STATUS_SERVER_CODENAME "Cruel Coconut"
#define STATUS_SERVER_PROTOCOL "8.54"
#define CLIENT_VERSION_MIN 854
#define CLIENT_VERSION_MAX 854
#define CLIENT_VERSION_STRING "Only clients with protocol 8.54 allowed!"
The server name wasn't changed, its made by The Forgotten team, they rule.
The server_version was changed so I know its for 8.54.
The server_protocol was changed to the one I needed 8.54.
The client_version_min was changed to 854 (same reason)
The client_version_max was changed to 854 (same reason)
The client_version_string was changed to 8.54 so the error messages would be correct.

If I understood correctly you an use it for multiple version OTservers but that wasn't needed now.
 
Before you tell me I didn't change the ip to my global, I changed it to my no-ip.org domain first (so it wasn't the 192.168.X.X anymore).

The first person that tested the third problem just told me he couldn't get further than the char list.
After I let someone else test and give me the error messages I understood what went wrong.

The ip-address i've set in servers.xml had to be a real ip-address and not an name-address.
I've changed it to my own ip and it works perfectly now.

Now its time to make a good server and get the site working (might give some errors).
 
While setting up gesior acc I'm running into more problems, even though gesior has support for multiple worlds it doesn't work completely as I want it to.

For example when one of the servers goes offline it says Server offline (right top) even though the login server + one of the other servers is still running.

Here is the code that belongs to this:
PHP:
$sock = @fsockopen($config['server']['ip'], $config['server']['statusPort'], $errno, $errstr, 1);
if ($sock)
{
fwrite($sock, $info);
$data='';
while (!feof($sock))
$data .= fgets($sock, 1024);
fclose($sock);
preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches);
$config['status']['serverStatus_online'] = 1;
$config['status']['serverStatus_players'] = $matches[1];
$config['status']['serverStatus_playersMax'] = $matches[2];
preg_match('/uptime="(\d+)"/', $data, $matches);
$h = floor($matches[1] / 3600);
$m = floor(($matches[1] - $h*3600) / 60);
$config['status']['serverStatus_uptime'] = $h.'h '.$m.'m';
preg_match('/monsters total="(\d+)"/', $data, $matches);
$config['status']['serverStatus_monsters'] = $matches[1];
}
else
{
$config['status']['serverStatus_online'] = 0;
$config['status']['serverStatus_players'] = 0;
$config['status']['serverStatus_playersMax'] = 0;
}
 
I've got it fixed with the help of stian.
I saw he also had several worlds and asked him how he did it.
Here's the code thats used now:

PHP:
// All credits to Stain for this!
$statustimeout = 20;
$config['status'] = parse_ini_file('config/serverstatus');
if($config['status']['serverStatus_lastCheck']+$statustimeout < time())
{
        $config['status']['serverStatus_checkInterval'] = $statustimeout+3;
        $config['status']['serverStatus_lastCheck'] = time();
        $info = chr(6).chr(0).chr(255).chr(255).'info';
        $servers = array('7171', '10041', '10042', '10043'); //Serverports have to be set here
               $config['status']['serverStatus_online'] = 0;
                $config['status']['serverStatus_players'] = 0;
                $config['status']['serverStatus_playersMax'] = 0;
        $config['status']['serverStatus_monsters'] = 0;
        $config['status']['serverStatus_uptime'] = 0;
        foreach ($servers as $server_port) {
        $sock = fsockopen('127.0.0.1', $server_port, $errno, $errstr, 2);
        if ($sock)
        {
                fwrite($sock, $info);
                $data='';
                while (!feof($sock))
                        $data .= fgets($sock, 1024);
                fclose($sock);

                preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches);
                if(!$config['status']['serverStatus_online'])
                        $config['status']['serverStatus_online'] = 1;
                $config['status']['serverStatus_players'] += $matches[1];
                $config['status']['serverStatus_playersMax'] += $matches[2];
                preg_match('/uptime="(\d+)"/', $data, $matches);

                $config['status']['serverStatus_uptime'] += $matches[1];
                preg_match('/monsters total="(\d+)"/', $data, $matches);
                $config['status']['serverStatus_monsters'] += $matches[1];
        }
	}
	$h = floor($config['status']['serverStatus_uptime'] / 3600);
        $m = floor(($config['status']['serverStatus_uptime'] - $h*3600) / 60);
        $config['status']['serverStatus_uptime'] = $h.'h '.$m.'m';
 
I've edited several things in whoisonline.php to make it show the servers almost like rl tibia (edited unnecessary things).
Here is a screen of how it looks:
whoisonline.jpg



I will post the new code later on or you can pm me for it.
 
I think its fixed, its looking as this now:

Servers.xml for login server:
Lua:
<servers>
        <server id="0" name="Server nr 0" address="192.168.X.X" port="7470"/>
        <server id="1" name="Server nr 1" address="192.168.X.X" port="7471"/>
</servers>
7470 is the game port of the first server
7471 is the game port of the second server

The servers are set as this:

Server1:
Lua:
Worldid ="0"
loginport ="7370"
gameport ="7470"
loginOnlyWithLoginServer = false
Server2:
Lua:
Worldid ="1"
loginport ="7371"
gameport ="7471"
loginOnlyWithLoginServer = false

The only error I get now is that my client should be 8.54, the login server only works with 8.50.

Hey, it works me with the local ip 192.168.*.* :D
Also it works me with 8.54 :p
I want to thank you because I was looking for the login server configuration few hours. It's strange that I found this in someone's problem but not in Tutorials.. ;*

I don't know how to fix your problems, sorry :/

I have one problem, can you explain me where I have to paste your script for online players when one serwer is offline?
 
Last edited:
Its in the layout.php of your website.

If you want you can post it here and I'll edit it.

Note: The 192.168.*.* only works for you and not for others, I had to change it later on.
 
Its in the layout.php of your website.

If you want you can post it here and I'll edit it.

Note: The 192.168.*.* only works for you and not for others, I had to change it later on.

1. I found it in config and functions...
2. If it really in layout.php I'll give :D
3. I wrote there my local and it works, actually 4 players are online :p

Ok, I did next actions:
1. I paste this into config and functions (I delete text similar to this)
2. It works but only for a few seconds, then it shows "0 Player Online" :((After those few seconds on the website I have "lag" and then it shows 0 :/)
 
Back
Top