Author Topic: Request server's details  (Read 4271 times)

0 Members and 1 Guest are viewing this topic.

Offline machina

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1117
  • The world isn't nice. Why should I be...?
Request server's details
« on: April 25, 2016, 11:29:31 am »
Hi,

Web lobby uses such request to get informations about currently running servers: https://soldat.pl/index.php?site=soldat&language=en&act=lobby&json=yes&reqs=gt=all`c=all`v=all`bots=all`locked=all`r=all`s=all`a=all`w=all`os=all`pl=all`namedItem=undefined`item=undefined`undefined=undefined.

My question is if there's any possibility to query for informations about a specific server - not all of them. So I would have a request like that (for example):
Code: [Select]
/getInfoAboutServer?ip=5.9.122.38:32076
Yea, I could query everything and search for the desired server but I wonder if there are extra possibilities.

And one would return JSON for that ip and port i.e.:
Code: [Select]
{"t":"#soldatladder","ip":"5.9.122.38:32076","gs":"3","pl":"0","c":"de","map":"HallOfHeroes","v":"1.7.0","mp":"32","bp":"0","os":"linux","pw":true,"info":""}
Also, if there is a way to query for more data than currently it is available with above request? Names of players those are playing on server for example.

Hopefully, I'm not asking something that was already answered elsewhere.

Thanks!

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: Request server's details
« Reply #1 on: April 25, 2016, 11:34:18 am »
No  ;)

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Request server's details
« Reply #2 on: April 25, 2016, 11:39:18 am »
You can download server's gamestats.txt via map port using soldat's file protocol. This would solve both of your issues (only one server, more data).

EDIT: More info here
« Last Edit: April 25, 2016, 11:41:02 am by FalconPL »
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: Request server's details
« Reply #3 on: April 25, 2016, 02:24:00 pm »
We could theoretically make such a json api for the lobby, but as falcon said you can just read gamestat.txt and parse that. Or parse refresh/refreshx if you have rcon access.
There are other worlds than these

Offline machina

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1117
  • The world isn't nice. Why should I be...?
Re: Request server's details
« Reply #4 on: April 26, 2016, 09:33:26 am »
Ugh, dunno what I'm doing incorrectly but I can't get that gamestat.txt file downloaded. I increased the port by 10 as it is said here. Then, I tried to get file with such request from the browser's address directly so it's HTTP GET (maybe that's wrong idea):
Code: [Select]
http://80.72.37.12:23083/logs/gamestat.txtMost probably my mistake has very simple solution but so I'm no more stuck and I don't have much time for digging I decided to ask you, guys :)

Btw. I'm not perfectly aware if this server has set Allow_Download=1 but I assumed that because this is a default value for Soldat.ini config file.

Offline machina

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1117
  • The world isn't nice. Why should I be...?
Re: Request server's details
« Reply #5 on: April 27, 2016, 11:18:17 am »
Okay! I got it working. Thanks for help, people ;)

This php script will show you players count on server:
http://pastebin.com/zKSdwa9y
Nice you wrote this snippet for me. I must admit though I abandoned using PHP in high school and currently I work only in Node :)

EDIT: I'm facing kind of issue that there is only the following text returned (and maybe some \r\n) instead of full information:
Quote
STARTFILES
It seems to happen randomly like there was kind of delay time between possibility to download gamestat.txt. I can get the full information only from time to time but most calls fail.

EDIT2: Now I could download data twice within 10 sec but later every call fails till 80 secs passes. Very random. Not sure if my script or Soldat's server's fault  :-\
« Last Edit: April 27, 2016, 01:02:21 pm by machina »