Page 1 of 1

Multiplayer Server GS-development

Posted: 06 Feb 2014 23:02
by Jamilian
Hi together,

I am currently starting to develop a small gamescript which should add some goals to a multiplayer games, and many more things. But its too early to explain this in details right now - I am just starting.
Is there somehow a possebility to get the results of the server-console command "clients" into the scripts? So the facts "which players are currently connected (multiplayer-playername); in which company (id) are they registered; and maybe "from which IP is the client connected"?

Up to now I couldn't find anything in this direction.

If anybody could help me with it, it would be a big help :)

Re: Multiplayer Server GS-deployment

Posted: 06 Feb 2014 23:48
by Zuu
Game scripts are natively not aware of clients. They can communicate with Admin Port clients which in turn have access to the console commands. Server GS is an example of the reverse: a GS that can be remotely controlled by a Admin port client. I don't know of any Admin port clients that offer the same to GSes.

Re: Multiplayer Server GS-deployment

Posted: 07 Feb 2014 00:05
by planetmaker
Jamilian wrote:Hi together,

I am currently starting to develop a small gamescript which should add some goals to a multiplayer games, and many more things. But its too early to explain this in details right now - I am just starting.
Is there somehow a possebility to get the results of the server-console command "clients" into the scripts? So the facts "which players are currently connected (multiplayer-playername); in which company (id) are they registered; and maybe "from which IP is the client connected"?

Up to now I couldn't find anything in this direction.

If anybody could help me with it, it would be a big help :)
Those are not exposed to game scripts. Scripts connected to the admin port have access to those information. In principle they can exchange info via json objects with a game script.

I'm not exactly convinced that it's a good idea to teach GS knowledge about player IPs, though; admin access is better faciliated via admin port directly.

Re: Multiplayer Server GS-deployment

Posted: 07 Feb 2014 11:34
by Jamilian
Well I will try to explain what I want to do, maybe you have other or better ideas how that could be realized.

The game script itself should become really simple in the first step. It should just check the companies quarterly value and create a ranking every year for example. And after the game ends (whenever the end is) it should create a final ranking including some some statistics for example. That is the first step.

In the next step this ranking should be done for companies as well as for players or maybe better, clients (so that it would become possible to say "player A and player B" are winning with company Z. (If they play together for example)

In the last step this information should become in any way exportable to write it for example in a mysql database, so that there could be a small webpage where the results of the last games are shown. And that again could become a server wide ranking for example.

And now back to my question, I think the best "ID" for a player over more than one game would be the multiplayer client name since the company name as well as the manager name are not that unique. Do you maybe have other ideas for this?

Jammy

Edit: corrected tablet typos

Re: Multiplayer Server GS-deployment

Posted: 07 Feb 2014 12:23
by planetmaker
you need to have the admin port script talk to the game script and vice versa anyway, if you want to export anything.

If it's only about simple global things like company value, you don't need a game script at all, that's available directly to admin port. You maybe want to focus on that first - though you'll then miss the display of the results ingame at the end of the game. If it's about more complex game statistics, and about displaying the stuff ingame, you'll indeed need a goal script - which then can communicate its findings via json objects to a script attached to the admin port. That admin port script can then do all it want, including updating web pages and databases with whatever information.

There's no better identification than the nickname of players available, maybe in conjunction with their IP - though the IP may change as may nickname.

Re: Multiplayer Server GS-deployment

Posted: 07 Feb 2014 12:38
by Zuu
Some MP services have a user database and require players to sign up on their website first with a nick + password. Then users join MP and send a private chat message to the server with their password. The admin port client receive this message and compare nick and password with the database. Note however that the password is sent without any encryption from OpenTTD clients to your server.

Re: Multiplayer Server GS-deployment

Posted: 09 Feb 2014 22:40
by Jamilian
Okay - then I think I have to focus first of all at the admin-scripts.

Currently I am trying to make my first steps with the python libottdadmin2. But up to now I was not able to open any test connection or anything like that. I will see, if I'll get it working; if not - could anyone of you give me a little instruction how to set up the libottdadmin2 and do anything to test the connectivity?

I thought I would install python, import/install the library and run a test script to test if the library works, but somehow; I'm missing a readme for the lib :D

Re: Multiplayer Server GS-deployment

Posted: 10 Feb 2014 06:47
by planetmaker
Jamilian wrote:Okay - then I think I have to focus first of all at the admin-scripts.

Currently I am trying to make my first steps with the python libottdadmin2. But up to now I was not able to open any test connection or anything like that. I will see, if I'll get it working; if not - could anyone of you give me a little instruction how to set up the libottdadmin2 and do anything to test the connectivity?

I thought I would install python, import/install the library and run a test script to test if the library works, but somehow; I'm missing a readme for the lib :D
With soap there does exist a full-fledged admin client which uses libottdadmin2. Maybe that can be of help?

Re: Multiplayer Server GS-deployment

Posted: 10 Feb 2014 11:02
by Taede
If you just need some example code, look in libottdadmin2's bin directory. It contains a few example scripts which make use of the lib, and is what I used when writing Soap.

Re: Multiplayer Server GS-deployment

Posted: 10 Feb 2014 16:08
by Jamilian
Taede wrote:If you just need some example code, look in libottdadmin2's bin directory. It contains a few example scripts which make use of the lib, and is what I used when writing Soap.
Well the thing is, im trying to do anything with the examples in /bin/. So I am trying to do any rcon command for example.

The Server is a Windows Server 2008 R2 with Python 2.7 installed (had 3.3 before but went back for troubleshooting)

This is the command i was trying, just for testing if the lib is working:
python openttd-admin-rcon.py -H 127.0.0.1 -P 3009 -p port! -v clients

And this is what happens:

C:\Python27\Scripts>openttd-admin-rcon.py -H 127.0.0.1 -P 3009 -p port! -v clients

Connecting to 127.0.0.1:3009
Traceback (most recent call last):
File "C:\Python27\Scripts\openttd-admin-rcon.py", line 43, in <module>
connection = AdminClient()
File "C:\Python27\lib\site-packages\libottdadmin2\client.py", line 123, in __i
nit__
self.__init_poll__()
File "C:\Python27\lib\site-packages\libottdadmin2\client.py", line 76, in __in
it_poll__
self._pollobj = poll()
NameError: global name 'poll' is not defined



Any idea whats wrong there?
Does the lib maybe only work on unix systems? Or whats wrong there?

Re: Multiplayer Server GS-deployment

Posted: 11 Feb 2014 21:28
by Jamilian
Okay got it. Tried the libottdadmin2 on a OpenSUSE and it works well.
So if anyone asks if the lib is only working on unix-based systems - looks like that.

Then i think the next step would be to export the Stats via the admin-port, isn't it?
Is here anyone who could give some explanations and examples about the usage of the admin-port and JSON commands?

Re: Multiplayer Server GS-development

Posted: 11 Feb 2014 22:34
by Zuu
You can check out Server GS which is a GS that expose the full GS API to Admin Port clients. (except for events where only one event is currently exposed)

To debug this GS I've made a test Admin Port client. However I made it in Java with the Joan library so it might be of limited use: http://devs.openttd.org/~zuu/JoanTest.zip

Also NoCarGoal (another GS by me) sends monthly goal progress reports to the admin port so that server owners that use this GS can feed that data to a public web server etc.

There might be other GSes with similar feature as in NoCarGoal that I'm just not aware of right now.


Edit: In the admin port client, remember to set update frequency to automatic for Game Script, otherwise you will NOT receive any JSON packets from the GS. This pit fall caught me when I tried to make my test client. :-)

Re: Multiplayer Server GS-development

Posted: 12 Feb 2014 12:42
by Jamilian
Okay, thanks for the tips - I'll play a bit with those as soon as I've got some spare time ;-)

And I'll keep this updated for anyone whos interested. And at anytime - if someone has general tips for the stuff I'm doing - just post it here :)