[TUT] BATTLEMETRICS (check list of games) status/map/players/most online/ server creat day/ AND MUCH MORE
Hey guys, I'm LeventHAN.
- Battalion 1944
- Rend
- PixARK
- Dark and Light
- ArmA 2
- Insurgency
- Rising Storm 2: Vietnam
- Insurgency: Sandstorm
- Post Scriptum
- Hell Let Loose
- Unturned
- SCUM
- Squad
- 7 Days to Die
- Counter-Strike: Source
- MORDHAU
- Counter-Strike
- Atlas
- ArmA 3
- Conan Exiles
- Garry's Mod
- DayZ
- Team Fortress 2
- Counter-Strike: Global Offensive
- ARK: Survival Evolved
- Rust
Today I will explain you how you can use Querry String to check the following information (by using API / PHP).
- Server Name
- IP / PORT
- ACTIVE PLAYERS
- MAX. SLOT OF PLAYERS
- COUNTRY OF SERVER
- STATUS (online/offline)
- Creat date of the server
- If there are mods
- modIDs
- mod names
- modHashes
- And much more
Now BATTLEMETRICS is a website where they store all the info about server. If you own the server you can even use RCON by API like kicking players/shuting down a server/ banning/ locking/etc... For more info check this: <API DOCUMENTS>
Lets start with the tutorial. I will now explain just SOME of what you can do. But when you get the idea you will be able to do the same with the other API Endpoints.
- SERVER STATUS + WICH MAP ARE WE PLAYING IN THE SERVER
- First we will check the whole code
Like you see there are defines and also explanation (so I don't need to do it now lol)
BUT what I'm going to explain now is the structure of the following code snippet:
if($response['data']['attributes']['status'] == "online") {
echo "ONLINE";
} else {
echo "OFFLINE";
};
So we made a if...else statement...
Inside the if we see response and than 3 variables. DATA > ATTRIBUTES > STATUS (See below for explanation of this path)
Let's we check what the API result look like:
So I did now coloured the json respond for a ARMA 3 server. ( https://api.battlemetrics.com/servers/5090469 ) (Also I did use a json beautifier to see the result better)
If you check the colors you will see that some of them are the same. Well I wanted to show the paths. But you can just copy the response from JSON/API and put it in a json beautifier like: <JSON BEAUTIFY>
For example I need to check wich MAP the server is right now.
We do this as follow:
<?php
$api = 'https://api.battlemetrics.com/servers/'; // the main API for servers.
$server = '5090469'; // the number of the server you will get the info from most of thime something like 5484856.
$api_full = $api . $server; // bringing them together.
$json = file_get_contents("$api_full"); // Putting the content of the file in a variable.
$response = json_decode($json, true); // decode the JSON feed
echo $response['data']['attributes']['details']['map'];
?>
> It will respond ALTIS. So we now know what people are playing (very usefull for csgo for example :P)
And here a extra code snippet to show the active players RIGHT NOW.
<?php
$api = 'https://api.battlemetrics.com/servers/'; // the main API for servers.
$server = '5090469'; // the number of the server you will get the info from most of thime something like 5484856.
$api_full = $api . $server; // bringing them together.
$json = file_get_contents("$api_full"); // Putting the content of the file in a variable.
$response = json_decode($json, true); // decode the JSON feed
echo $response['data']['attributes']['players'];
?>
I'm done I think... If you have question with API/JSON - PHP let me know I'm kinda good at it :))
AND also for other things regarding GLC v2

-
Battlemetrics API Code Snippets
8 months ago
Latest Post: Loop downloading Our newest member: Karen Flaten Recent Posts Unread Posts Tags
Forum Icons: Forum contains no unread posts Forum contains unread posts
Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed