Dedicated server with highscore?
Moderator: OpenTTD Developers
-
- Engineer
- Posts: 2
- Joined: 03 Feb 2007 19:01
Dedicated server with highscore?
Hi
I have a couple questions about OpenTTD when running as dedicated server.
1. Is it possible to dump all the companies finances/results in a file(.txt) after x amount of years? or when the game is ending?
2. If not. Is it possible to somehow make the server take a screenshot of all the companies final finances when the game ends?
I want my server to automaticly take screens or dump highscores to a file when a openttd game ends, so im asking if t here is a easy way to do this?
I have a couple questions about OpenTTD when running as dedicated server.
1. Is it possible to dump all the companies finances/results in a file(.txt) after x amount of years? or when the game is ending?
2. If not. Is it possible to somehow make the server take a screenshot of all the companies final finances when the game ends?
I want my server to automaticly take screens or dump highscores to a file when a openttd game ends, so im asking if t here is a easy way to do this?
-
- Engineer
- Posts: 2
- Joined: 03 Feb 2007 19:01
I really think that this would be possible..
With a bit of work and a 'kludge' of a few different ideas I really this that this
could be done...
I have been looking for some ideas to 'Sink My Teath' into and this is something
that i am going to take on..
With the Help of people like 'Brianetta' and others from the community this
shouldn't be to hard..
I will report back as soon as I have something, even if it is to say, "ITS IMPOSSIBLE & it is making me want to pull out all of my Hair !!!"
With a bit of work and a 'kludge' of a few different ideas I really this that this
could be done...
I have been looking for some ideas to 'Sink My Teath' into and this is something
that i am going to take on..
With the Help of people like 'Brianetta' and others from the community this
shouldn't be to hard..
I will report back as soon as I have something, even if it is to say, "ITS IMPOSSIBLE & it is making me want to pull out all of my Hair !!!"
right...
Brianetta in post 540872 @ http://www.tt-forums.net/viewtopic.php?p=540872#540872
you posted the code of your Banner Script...
With this script you used TCL to send a UDP query to the server and then
annotate that info onto a png...
Can we not just use this info and output it to 1.) a txt file or 2.) a MySQL DB...
The main info needed would be the Company Info... ie Company Value and so on...
Would that work ?
Comments/Suggestions/Flames anything Welcome...
Brianetta in post 540872 @ http://www.tt-forums.net/viewtopic.php?p=540872#540872
you posted the code of your Banner Script...
With this script you used TCL to send a UDP query to the server and then
annotate that info onto a png...
Can we not just use this info and output it to 1.) a txt file or 2.) a MySQL DB...
The main info needed would be the Company Info... ie Company Value and so on...
Would that work ?
Comments/Suggestions/Flames anything Welcome...
Yes, it's trivial to write it to a text file. I use something very similar to generate the dynamic content on the web page that the graphic in my signature links to. Also writing to a database is simple enough; the openttd server list works exactly like that, except that it's written in PHP, not Tcl.
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
What comment would you have to send to the Server (via UDP) to
ask about the info that is shown when you get to the Join Screen in OpenTTD ?
like in the Picture below:-

I have tried to 'sniff the packets' but i just cant find the command to send
to the server...
Is this info inside the 'PACKET_SERVER_GAME_INFO' command ?
It must be there somewhere, or how would the Client get it ?
This info is 110% what we are looking for. If we could get this we could make
a High Score system without any problem...
Maybe and OpenTTD Developer can help...
ask about the info that is shown when you get to the Join Screen in OpenTTD ?
like in the Picture below:-
I have tried to 'sniff the packets' but i just cant find the command to send
to the server...
Is this info inside the 'PACKET_SERVER_GAME_INFO' command ?
It must be there somewhere, or how would the Client get it ?
This info is 110% what we are looking for. If we could get this we could make
a High Score system without any problem...
Maybe and OpenTTD Developer can help...
Part of that information is acquired via UDP (you send PACKET_UDP_CLIENT_FIND_SERVER and get a PACKET_UDP_SERVER_RESPONSE back).
The other part is acquired via TCP (you send PACKET_CLIENT_COMPANY_INFO and get a PACKET_SERVER_COMPANY_INFO back).
Those are respectively NetworkUDPQueryServer and NetworkTCPQueryServer in the trunk code.
The other part is acquired via TCP (you send PACKET_CLIENT_COMPANY_INFO and get a PACKET_SERVER_COMPANY_INFO back).
Those are respectively NetworkUDPQueryServer and NetworkTCPQueryServer in the trunk code.
"By Joe, I Think I Have Done It !!"
I think I've done it...
My servers now all Output the 'player' command to a txt file on the www server.
This data is then ready to be read by a script to 'collate' the information.
and example of the files can be seen @ http://openttd.dageek.co.uk/DaGeek_Serv ... xample.txt
(this is not a dynamic updating example, This is just to show an example of the data)
Now all we/I have to do is make the PHP end of things to show these details
in a nicer way to the end user, and then also make some kind of 'Score History' page as well....
If I can get these values into a MySQL DB we can even start to make some nice pretty graphs..
"wow" I hear you say...
Well O.K. maybe not, but I can dream...
My servers now all Output the 'player' command to a txt file on the www server.
This data is then ready to be read by a script to 'collate' the information.
and example of the files can be seen @ http://openttd.dageek.co.uk/DaGeek_Serv ... xample.txt
(this is not a dynamic updating example, This is just to show an example of the data)
Now all we/I have to do is make the PHP end of things to show these details
in a nicer way to the end user, and then also make some kind of 'Score History' page as well....
If I can get these values into a MySQL DB we can even start to make some nice pretty graphs..
"wow" I hear you say...
Well O.K. maybe not, but I can dream...

-
- Engineer
- Posts: 2
- Joined: 11 Feb 2007 00:22
- Contact:
Hmm I tried to get something via PHP... But I never had to use such connections in PHP before... How do I send the packets to the server and how do I read out the answer then?
I guess I need fsockopen or something..
\\edit:
okay I got it plotting something from the UDP port...
http://shadowdrinker.no-ip.com/OTTD/udp.php
but that is quite few information... and it doesn't work with tcp:// at all!
I guess I need fsockopen or something..
\\edit:
okay I got it plotting something from the UDP port...
http://shadowdrinker.no-ip.com/OTTD/udp.php
but that is quite few information... and it doesn't work with tcp:// at all!
English is not my native language, so please excuse me if I sometimes might appear a bit harsh or if I make a spelling or grammar mistake!
This UDP example is from the PHP.net site...thistle wrote: do you need to specify the tcp:// ? can't you just use the IP address in fscockopen?
I've just tried sending and reading a UDP query but can't get it to do anything on my setup.
Code: Select all
<?php
$fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
fwrite($fp, "\n");
echo fread($fp, 26);
fclose($fp);
}
?>
Code: Select all
<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
I have almost finished my Add-On to autopilot that will pull game stats from
a running server.
Is is a very very simple (but some will say messy) way of getting the stats,
The Add-On will pull the data strait from the Console of the running server
and output it to some txt files.. (This bit alrealy works fine, examples @
http://openttd.dageek.co.uk/DaGeek_Server99_score.txt
&
http://openttd.dageek.co.uk/DaGeek_Server99_stats.txt
)
The other parts of the Add-On are for the Auto Screenshots that you can see
@ http://openttd.dageek.co.uk (Major thanks goes out to Brianetta
who has pointed me in the right direction on this bit)
The last thing I'm working on @ the mo is the www interface to show all these
details in a nice way...
a running server.
Is is a very very simple (but some will say messy) way of getting the stats,
The Add-On will pull the data strait from the Console of the running server
and output it to some txt files.. (This bit alrealy works fine, examples @
http://openttd.dageek.co.uk/DaGeek_Server99_score.txt
&
http://openttd.dageek.co.uk/DaGeek_Server99_stats.txt
)
The other parts of the Add-On are for the Auto Screenshots that you can see
@ http://openttd.dageek.co.uk (Major thanks goes out to Brianetta
who has pointed me in the right direction on this bit)
The last thing I'm working on @ the mo is the www interface to show all these
details in a nice way...
Ok this is a total noob question because I've never really played with this sort of stuff before:
How do I send a packet to the server in PHP?
I've opened a (TCP) socket with fsockopen and then fwrote "PACKET_CLIENT_COMPANY_INFO" to the socket.
In the dedicated server console window the connection shows up, but when I try to fread a reply, I don't get anything.
If I do something similar with UDP and write "PACKET_UDP_CLIENT_FIND_SERVER" to the socket then the console window shows:
Do I need to so some magic encoding with the packet to get a reply?
My entire code is below, and it works fine when sending a HTTP request to a local web server:
How do I send a packet to the server in PHP?
I've opened a (TCP) socket with fsockopen and then fwrote "PACKET_CLIENT_COMPANY_INFO" to the socket.
In the dedicated server console window the connection shows up, but when I try to fread a reply, I don't get anything.
If I do something similar with UDP and write "PACKET_UDP_CLIENT_FIND_SERVER" to the socket then the console window shows:
Code: Select all
Recieved Invalid packet type 67 from 192.168.1.101:1300
My entire code is below, and it works fine when sending a HTTP request to a local web server:
Code: Select all
<?PHP
//script for querying an openttd server and displaying the response
$server = "192.168.1.101";
$port = 3979;
$packet = "PACKET_CLIENT_COMPANY_INFO";
$socket = fsockopen($server, $port, $errno, $error, 30);
fwrite($socket, $packet);
while (!feof($socket)) {
echo fread($socket, 64);
}
fclose($socket);
?>
Last edited by thistle on 15 Feb 2007 16:27, edited 1 time in total.
Who is online
Users browsing this forum: No registered users and 2 guests