Jump to content

Help how to add Whole ETS2MP game Servers status to my website?


NoMoreFury

Recommended Posts

Hello guys i have an question that i need to know how to add ETS2mp game Servers status on my WEbsite This a Little question that i asked Please help me :)

MY IN-Game Status Is:

image.png

 

Feel Free to Add me on Steam :)

 

 

76561198134431931.png

 

My pc specs

(Updated)

[url=https://valid.x86.fr/212q0h][img]https://valid.x86.fr/cache/banner/212q0h-5.png[/img][/url]

Link to comment
Share on other sites

MY IN-Game Status Is:

image.png

 

Feel Free to Add me on Steam :)

 

 

76561198134431931.png

 

My pc specs

(Updated)

[url=https://valid.x86.fr/212q0h][img]https://valid.x86.fr/cache/banner/212q0h-5.png[/img][/url]

Link to comment
Share on other sites

  • DevOps

@mwi4 can you make a video of it i cant understand please :(

If you're not sure how to parse the api it may just be better idea to link to the status page. It can be complex if you do not know how to with php or language of your choice.

Traffic Cameras : twitch.tv/kat_pw | Ets2Map : ets2map.com
Kat_pw Status:image.png[CCTV #1] Status:image.png[CCTV #2] Status:image.png[CCTV #3] Status:image.png

Link to comment
Share on other sites

^ problem with C&P is you are consuming the servers resources. the API sends raw data which can be put into various pieces which a web dev could make use of

 

example php you can use explode based on "{"

using said expression it should do this:

"error":"false","response":["id":1,"ip":"1.eu.game.ets2mp.com","port":42850,"name":"Europe #1","shortname":"EU #1","online":true,"players":926,"maxplayers":2300,"speedlimiter":1},"id":3,"ip":"1.us.game.ets2mp.com","port":42850,"name":"United states #1","shortname":"US #1","online":false,"players":0,"maxplayers":1500,"speedlimiter":1},"id":4,"ip":"2.eu.game.ets2mp.com","port":42880,"name":"Europe #2","shortname":"EU #2","online":true,"players":112,"maxplayers":2300,"speedlimiter":1}]}

Next would be using another explode. HOWEVER this is resource intensive (or can be)

 

using the same method as you said to grab the code you can use the same function to collect the API info. It's called cURL it request the website and using various functions you can collect the code in one line break it down and echo or collect as needed. i had one from back in my RuneScape days (3+ years ago) but i have had HDD failure/corruption since then... But the function you need will be preg_match i believe for php (equal in other program languages).

 

ONLY request server updates every min MAX, as they only update it every minute. personally 5 minutes should work... This can be set via a cron job

Signature removed by a wondering ghost

SUS0M9O.gif

Link to comment
Share on other sites

^ problem with C&P is you are consuming the servers resources. the API sends raw data which can be put into various pieces which a web dev could make use of

 

example php you can use explode based on "{"

using said expression it should do this:

"error":"false","response":["id":1,"ip":"1.eu.game.ets2mp.com","port":42850,"name":"Europe #1","shortname":"EU #1","online":true,"players":926,"maxplayers":2300,"speedlimiter":1},"id":3,"ip":"1.us.game.ets2mp.com","port":42850,"name":"United states #1","shortname":"US #1","online":false,"players":0,"maxplayers":1500,"speedlimiter":1},"id":4,"ip":"2.eu.game.ets2mp.com","port":42880,"name":"Europe #2","shortname":"EU #2","online":true,"players":112,"maxplayers":2300,"speedlimiter":1}]}
Next would be using another explode. HOWEVER this is resource intensive (or can be)

 

using the same method as you said to grab the code you can use the same function to collect the API info. It's called cURL it request the website and using various functions you can collect the code in one line break it down and echo or collect as needed. i had one from back in my RuneScape days (3+ years ago) but i have had HDD failure/corruption since then... But the function you need will be preg_match i believe for php (equal in other program languages).

 

ONLY request server updates every min MAX, as they only update it every minute. personally 5 minutes should work... This can be set via a cron job

may I point your attention to json_decode()? Explode is a bad idea, usually will cause you more trouble than good. Same goes for "preg_match"(aka. regex.) Here's blog post by Jeff Atwood on why regex is a bad idea in a scenario like this.

 

If you still can't figure it out, I'd suggest picking up a good book on php 5.6(or 5.5, but nothing older!) and learn how to write php. Alternatively have a look at Code Academy I've followed their python track myself and that seemed to be pretty good.

 

Why not just "copy" the status page basically? (I haven't looked at the source yet but I'm sure you could just copy it lol )

Nope, the new status page is server side, so if you copy it, you'll only get the current count and it won't update.
Link to comment
Share on other sites

Next to creating a custom link/page on your forum tuxyQ and I have given you all the required answers

Also if you want to collect the data you display you will need to learn the new SQL methods of connecting, reason is while it's still being maintained (bugs etc) it'll eventually die. I've yet to select my new flavor but I've not had time to read up on either

http://php.net/manual/en/mysqlinfo.api.choosing.php

Also a good reason to pick up a book or anything 5.5 or newer as stated by tux, tho i know tons things changed between said versions. I'm running 5.3 on my servers, but once I get time to I'll be upgrading to the newest

If you ask tux nicely they might make you a simple script. I don't really have time too. But imo it be a good idea to try it your self first ;)

@tuxyQ

I bumped into the json decode while I was working on the runescape stuff but I never could use it (not sure if they have a API now, but nor do I care lol).

Equally forgot about said command...

Signature removed by a wondering ghost

SUS0M9O.gif

Link to comment
Share on other sites

Next to creating a custom link/page on your forum tuxyQ and I have given you all the required answers

Also if you want to collect the data you display you will need to learn the new SQL methods of connecting, reason is while it's still being maintained (bugs etc) it'll eventually die. I've yet to select my new flavor but I've not had time to read up on either

http://php.net/manual/en/mysqlinfo.api.choosing.php

Also a good reason to pick up a book or anything 5.5 or newer as stated by tux, tho i know tons things changed between said versions. I'm running 5.3 on my servers, but once I get time to I'll be upgrading to the newest

If you ask tux nicely they might make you a simple script. I don't really have time too. But imo it be a good idea to try it your self first ;)

@tuxyQ

I bumped into the json decode while I was working on the runescape stuff but I never could use it (not sure if they have a API now, but nor do I care lol).

Equally forgot about said command...

so  can you make it for me for ipboard forums?

Script?

MY IN-Game Status Is:

image.png

 

Feel Free to Add me on Steam :)

 

 

76561198134431931.png

 

My pc specs

(Updated)

[url=https://valid.x86.fr/212q0h][img]https://valid.x86.fr/cache/banner/212q0h-5.png[/img][/url]

Link to comment
Share on other sites

For IPb I'd say learn how to do the script yourself, when(and it will) it breaks, you will also know how to fix it.

Also if you want to collect the data you display you will need to learn the new SQL methods of connecting, reason is while it's still being maintained (bugs etc) it'll eventually die. I've yet to select my new flavor but I've not had time to read up on either

http://php.net/manual/en/mysqlinfo.api.choosing.php

Today I'd say don't bother with doing mysql the hard way, use an ORM like Doctrine, Idiorm(my personal favorite) or Redbean.
Link to comment
Share on other sites

No time, a 3 day convention is this weekend (Friday-Sunday), work, and this: http://forum.ets2mp.com/index.php?/topic/12912-the-most-comprehensive-suggestion-ever-xd/

All you need is 2 files.

One to collect the API every x min (as stated 5 should work)

One to display on the site.

This well prevent your users from requesting the API server every time they load your page ;)

I like to keep busy :)

Edit: tux your fav looks like mysql pdo lol

Signature removed by a wondering ghost

SUS0M9O.gif

Link to comment
Share on other sites

Edit: tux your fav looks like mysql pdo lol

It's basicly PDO, but not restricted to mysql, so if you decide to add point data it'll use any of the supported DBRM's native datatype for it (eg. Postgres or Mysql 5.6 has datatypes for point and other spacial data formats)
Link to comment
Share on other sites

^ problem with C&P is you are consuming the servers resources. the API sends raw data which can be put into various pieces which a web dev could make use of

 

example php you can use explode based on "{"

using said expression it should do this:

"error":"false","response":["id":1,"ip":"1.eu.game.ets2mp.com","port":42850,"name":"Europe #1","shortname":"EU #1","online":true,"players":926,"maxplayers":2300,"speedlimiter":1},"id":3,"ip":"1.us.game.ets2mp.com","port":42850,"name":"United states #1","shortname":"US #1","online":false,"players":0,"maxplayers":1500,"speedlimiter":1},"id":4,"ip":"2.eu.game.ets2mp.com","port":42880,"name":"Europe #2","shortname":"EU #2","online":true,"players":112,"maxplayers":2300,"speedlimiter":1}]}

Next would be using another explode. HOWEVER this is resource intensive (or can be)

 

using the same method as you said to grab the code you can use the same function to collect the API info. It's called cURL it request the website and using various functions you can collect the code in one line break it down and echo or collect as needed. i had one from back in my RuneScape days (3+ years ago) but i have had HDD failure/corruption since then... But the function you need will be preg_match i believe for php (equal in other program languages).

 

ONLY request server updates every min MAX, as they only update it every minute. personally 5 minutes should work... This can be set via a cron job

 

Or you could just use the json_decode function! To read the JSON data, you can simply use the fopen function and pass the url as the filename.

No need to re-invent the wheel here.

 

You could than pass the returned array to your template engine and render the data on your website.

510 Horses and one lucky bird at work


Simulators: Prepar3d V4, X-Plane 11, DCS 1.5 + 2.x, ETS2, ATS, Farming Simulator 17, Omsi 1 + 2

System: Intel i7-6700K @ 4700Mhz, 32GB DDR4 Corsair Vengeance LPX, GTX970,  HP LP2475w monitor (1920x1200)
Devices: Logitech G27, SKRS Shifter, CH Products Throttle Quadrant, Trustmaster Hotas Joystick, TrackIR
Storage: 2 x SM961 - 250GB (raid 0), Samsung 850 pro 1TB disk, Samsung 850 EVO 2TB disk.

 

Link to comment
Share on other sites

^If you had bothered reading the topic, you'd already see that I said that…

 

relying on fopen is also a generally bad idea as many hosts set allow_url_fopen to false and direct you to utilize curl.

Link to comment
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.