JND_3004 Posted June 9, 2017 Share Posted June 9, 2017 Hi guys, Is there a way with PHP to find out his TruckersMPID using the InGame ID (1234)? For example with the API: https://api.truckersmp.com/v2/servers/{server_id}/{ingame_id} Since the API does not issue this option, I wanted to create this via the chat log of ETS2MP, but the logs are corrupted because PHP can not read the file properly. Do you have a solution for my problem? Link to comment Share on other sites More sharing options...
BOSSENTERPRiSES Posted June 9, 2017 Share Posted June 9, 2017 8 minutes ago, JND_3004 said: Hi guys, Is there a way with PHP to find out his TruckersMPID using the InGame ID (1234)? For example with the API: https://api.truckersmp.com/v2/servers/{server_id}/{ingame_id} Since the API does not issue this option, I wanted to create this via the chat log of ETS2MP, but the logs are corrupted because PHP can not read the file properly. Do you have a solution for my problem? I do not have enough knowledge about PHP or API, but you can type "/pinfo ID" to learn the TruckersMP ID of a player. For example if you want to see the TruckersMP ID of the player "385", you can type "/pinfo 385" to see the player's TruckersMP ID. (Type without inverted commas.) Link to comment Share on other sites More sharing options...
JND_3004 Posted June 9, 2017 Author Share Posted June 9, 2017 Just now, BOSSENTERPRiSES said: I do not have enough knowledge about PHP or API, but you can type "/pinfo ID" to learn the TruckersMP ID of a player. For example if you want to see the TruckersMP ID of the player "385", you can type "/pinfo 385" to see the player's TruckersMP ID. (Type without inverted commas.) Thanks for your answer. I also know that I could work in the game with /pinfo, but I would like to work with PHP, so in my case /pinfo unfortunately uses nothing. Sorry for my english. 1 Link to comment Share on other sites More sharing options...
Scar Posted June 9, 2017 Share Posted June 9, 2017 This isn't possible at the moment with the current API. Scar | Retired Legend You can design and create, and build the most wonderful place in the world. But it takes people to make the dream a reality. Banned: HELP! - Report a player - Help - Rules - Staff recruitment - Complaints/feedback Link to comment Share on other sites More sharing options...
CJMAXiK Posted June 9, 2017 Share Posted June 9, 2017 You can do this using ETS2Map API, but there is no public API for that, so... Link to comment Share on other sites More sharing options...
JND_3004 Posted June 9, 2017 Author Share Posted June 9, 2017 But can not something like that be included in the API? 4 hours ago, scarface0359 said: This isn't possible at the moment with the current API. I know .. 3 hours ago, CJMAXiK [RU] said: You can do this using ETS2Map API, but there is no public API for that, so... Yes, unfortunately :/ Link to comment Share on other sites More sharing options...
Usersrrr Posted July 1, 2017 Share Posted July 1, 2017 Hi, That's how I wrote it-to get how many players are online //Must be jquery.min.js var mp = { sersers: function() { $.getJSON('https://api.truckersmp.com/v2/servers', { }, function(data) { var result = data; var id = result.response[2]['id']; //respons['2'] - this server 1,2,3,4 var players = result.response[2]['players']; if (id) { $('.onlinemp').find("#result").text(players); $('#count').text(declOfNum(players, ['player', 'player', 'players'])); } setTimeout(function() { mp.sersers(); }, 5000); }); } } function declOfNum(number, titles) { cases = [2, 0, 1, 1, 1, 2]; return titles[(number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5]]; } <span class="onlinemp">Server status Europe 2: <span id="result"></span> <span id="count"></span> online</span> <script type="text/javascript"> mp.sersers(); </script> Link to comment Share on other sites More sharing options...
JND_3004 Posted July 1, 2017 Author Share Posted July 1, 2017 3 hours ago, Usersrrr said: Hi, That's how I wrote it-to get how many players are online //Must be jquery.min.js var mp = { sersers: function() { $.getJSON('https://api.truckersmp.com/v2/servers', { }, function(data) { var result = data; var id = result.response[2]['id']; //respons['2'] - this server 1,2,3,4 var players = result.response[2]['players']; if (id) { $('.onlinemp').find("#result").text(players); $('#count').text(declOfNum(players, ['player', 'player', 'players'])); } setTimeout(function() { mp.sersers(); }, 5000); }); } } function declOfNum(number, titles) { cases = [2, 0, 1, 1, 1, 2]; return titles[(number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5]]; } <span class="onlinemp">Server status Europe 2: <span id="result"></span> <span id="count"></span> online</span> <script type="text/javascript"> mp.sersers(); </script> Have you really read my post? i think no. I will not results from player count from a server ... Please read my start post Link to comment Share on other sites More sharing options...
Usersrrr Posted July 1, 2017 Share Posted July 1, 2017 I from Russia and badly understand what you need, if you well described your problem I might help you out. Link to comment Share on other sites More sharing options...
JND_3004 Posted July 3, 2017 Author Share Posted July 3, 2017 On 6/9/2017 at 4:32 AM, JND_3004 said: Thanks for your answer. I also know that I could work in the game with /pinfo, but I would like to work with PHP, so in my case /pinfo unfortunately uses nothing. Sorry for my english. Thanks for your answer. I also know that I could work in the game with /pinfo, but I would like to work with PHP, so in my case /pinfo unfortunately uses nothing. Sorry for my english. Link to comment Share on other sites More sharing options...
Orang-e Posted July 8, 2017 Share Posted July 8, 2017 Its very easy to find out TruckersMP ID if you know the Player id & Server. Here is the PHP code: <?php $give_pid = $_POST['p_id'];// Input this from html form. $give_server = $_POST['server']; // There can be multiple people with same pid on different servers. so we take server as input also $url = "http://tracker.ets2map.com/v2/fullmap"; $response = file_get_contents($url); $trucks = json_decode($response); foreach($trucks->Trucks AS $truck){ if($truck->p_id == $give_pid && $truck->server == $give_server){ $find_mp_id = $truck->mp_id; $flag=0; break; }else{ $flag=1; } if($flag != 1){ echo $find_mp_id; }else{ echo "Not Found"; } //SERVER ID can be found here https://api.truckersmp.com/v2/servers ?> WARNING: The API that is returning server info shows wrong server id. For all those who are saying its not possible.. please do some research. Then come to a conclusion. 1 Link to comment Share on other sites More sharing options...
JND_3004 Posted July 8, 2017 Author Share Posted July 8, 2017 (edited) ^ Best man Thanks! Edited July 8, 2017 by Anriandor Removed unnecessary quotation. Link to comment Share on other sites More sharing options...
Orang-e Posted July 8, 2017 Share Posted July 8, 2017 The Server List API is showing a different server id as compared to ETS2MAP api. you might have to manually add the correct id with their server names in a table. Example: server_name server_id ETS2 EU2 2 ETS2 EU4 7 Link to comment Share on other sites More sharing options...
JND_3004 Posted July 8, 2017 Author Share Posted July 8, 2017 (edited) ^ Yeap, i know Thanks Edited July 8, 2017 by Anriandor Removed unnecessary quotation. Link to comment Share on other sites More sharing options...
Recommended Posts