Limited server access

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
Ravenamp
Engineer
Engineer
Posts: 3
Joined: 22 Mar 2010 12:21

Limited server access

Post by Ravenamp »

Hello,

I've setup an openttd server a while ago, but haven't used it until now. The reason is I would like to play some games with a couple of friends but the game takes simply way too long to finish and it would be unfair because one person could play several hours a day while the other ones only have time to play like an hour a day. Therefore I would like to change the following setting:

- Limit playingtime to 30 minutes a day for each player or company. Is there a way to force clients to play no more then xx minutes per day?
- Limit the number of goals to reach before winning the game. Is there a way to define the number of trains/stations one needs to build, cargo one needs to deliver etc.?

If this is not possible I would like to coin these as feature requests to the developers :) I'm sure A LOT of players would like these features!

I hope someone can help me out here.

Greetz,

Raven
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Limited server access

Post by Zuu »

Write your own autopilot/ap+ clone that keeps track of the play time of your friends and when they have played for more than 30 minutes, you force move them from their company to the spectators. Perhapas also combine with the setting to pause the game if less than X players are present. You sholud probably make your autopilot clone such that it does not count time when the game is paused if you set X > 1 player.

autopilot/ap+ are both written in tcl/tk if I remember correctly. You can write your clone in any language you like. Preferable a programming language that you are familar with in which it is easy to compare strings. If you are on windows you should check out glx' tool to convert openttd into a console program so that your autopilot can use stdin/stdout to communicate with OpenTTD.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Limited server access

Post by petert »

Zuu wrote:If you are on windows you should check out glx' tool to convert openttd into a console program so that your autopilot can use stdin/stdout to communicate with OpenTTD.
I've tried running AutoPilot/ap+ on Windows, and it wasn't possible because whatever bash I ran it from didn't find the package Expect (even thought it was installed).
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Limited server access

Post by Zuu »

petert wrote:
Zuu wrote:If you are on windows you should check out glx' tool to convert openttd into a console program so that your autopilot can use stdin/stdout to communicate with OpenTTD.
I've tried running AutoPilot/ap+ on Windows, and it wasn't possible because whatever bash I ran it from didn't find the package Expect (even thought it was installed).
I didn't meant that he should run 'autopilot' or 'ap+' but his own autopilot clone. I wrote "your autopilot" not "the autopilot", but I could have been more clear.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Ravenamp
Engineer
Engineer
Posts: 3
Joined: 22 Mar 2010 12:21

Re: Limited server access

Post by Ravenamp »

Sorry for my late reply...

Hmm, so there is no standard way to do it I assume.
I am a java-programmer and I know some C and bash, but I think your suggestion might take me too long to figure out. To start with I have no idea what you're talking about :P
Although this was not the answer I was hoping for, thank you very much for taking the trouble... :bow:

So, how about limiting the number of goals?

I am running Ubuntu 9.04 on my webserver btw.
Last edited by Ravenamp on 25 Mar 2010 21:03, edited 1 time in total.
Ravenamp
Engineer
Engineer
Posts: 3
Joined: 22 Mar 2010 12:21

Re: Limited server access

Post by Ravenamp »

So, I understand this auto-pilot thingy is a script which is able to communicate commands to my server and it needs a tcl-interpreter. So, I haven't read much yet, because I have to go now, but I assume I can give instructions to this script from my commandline, and thus from any other language like, say, a crontabbed sh-script which is executed to ban/unban players?
I have seen such functionality in gameservers before... Am I on the right track here? Or is there a better/more elegant way?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Limited server access

Post by Zuu »

ap+ and autopilot are two public available scripts/programs that as you guessed communicate with OpenTTD. Since neither of them does what you want to do you can either try to modify them to do or write your own script/program. I once wrote a simple ruby script that ran hour long quick games in OpenTTD, greeted players and told everyone about when it was just 5 minutes left etc. If your primary language is Java, I would suggest that you write something in Java.

What this program/script does:

* Start OpenTTD in dedicated mode (-D argument)
* Hookup standard input/output of OpenTTD with the program/script. You probably want to have a separate thread that is connected with standard output of OpenTTD as in many languages you have to have a blocking routine that reads the output from OpenTTD as input to your program. For easier coding you could make this thread just put everything in a queue that your main thread then will pop messages from.
* Read messages from OpenTTD and match them against some patterns/strings to detect the events that you want to detect. If you want to react on something send commands to the OpenTTD server through standard input of OpenTTD.

To limit play time you should be able to read join/quit messages of players and do some book keeping to keep track of the play time and then kick/move players that has exceeded the time. Either kick them out of the game or move them to spectators where they can only watch, but not do anything. You probably will need to code it so that there is maximum say 30 min playtime per company rather than per player, as they otherwise could change their nick and get around the limitation.

As long as you know programming well enough this shouldn't be a problem. You can run OpenTTD -D manually and observe the log messages and read about which commands that exist.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Limited server access

Post by planetmaker »

Ravenamp wrote:So, I understand this auto-pilot thingy is a script which is able to communicate commands to my server and it needs a tcl-interpreter. So, I haven't read much yet, because I have to go now, but I assume I can give instructions to this script from my commandline, and thus from any other language like, say, a crontabbed sh-script which is executed to ban/unban players?
I have seen such functionality in gameservers before... Am I on the right track here? Or is there a better/more elegant way?
Yes, that's about right. For those things mentioned by Zuu you can write simple plug-in tcl scripts which ap+ will then recognize and use.

You might also want to look at avignon, the newest member of the wrapper programmes which are capable to run OpenTTD.
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: Google [Bot] and 2 guests