Guest User

wowowiwa

a guest
Sep 9th, 2020
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <!-- sauertracker server stats jquery/JSON -->
  3. <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  4.  
  5.  
  6. <script>
  7. var yourip = document.getElementsByTagName("body")[0].ip;
  8. //window.alert("your IP before " + yourip); (returns undefined)
  9. $.getJSON("https://jsonip.com?callback=?", function (response) {
  10.    yourip = response.ip;
  11.    $("#ip").text(response.ip);
  12.    window.alert("your IP: " + yourip);
  13. });
  14.  
  15. $.getJSON("https://sauertracker.net/api/v2/server/"+yourip+"/12345", function(data) {
  16.    
  17.    var text = `Clients: ${data.clients}
  18.    <br>Mastermode: ${data.masterMode}
  19.    <br>Mode: ${data.gameMode}
  20.    <br>Map: ${data.mapName}
  21.    <br>Time left: ${data.timeLeftString}<hr>`
  22.    $(".serverinfo").html(text);
  23.    
  24.    for (i in data.players) {
  25.       $("body").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &bull; Name: " + data.players[i].name
  26.       + ", Frags: " + data.players[i].frags
  27.       + ", Deaths: " + data.players[i].deaths
  28.       + ", Teamkills: " + data.players[i].tks
  29.       + ", KPD: " + data.players[i].kpd
  30.       + ", Accuracy: " + data.players[i].acc + "%"
  31.       + ", Flags: " + data.players[i].flags
  32.       + ", Team: " + data.players[i].team
  33.       + ", Country: " + data.players[i].countryName
  34.       + ", Ping: " + data.players[i].ping
  35.       + "&nbsp;&nbsp;<a href='https://sauertracker.net/players' id='gotoClientStats' target='_blank'> See More Stats</a>"
  36.       + "<br><hr>");
  37.       document.getElementById("gotoClientStats").href = "https://sauertracker.net/players/find?name=" + data.players[i].name;
  38.    }
  39.    for (i in data.teams) {
  40.       $("body").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Team: " + data.teams[i].name
  41.       + ", Score: " + data.teams[i].score+"<br><br>");
  42.    }
  43. });
  44. </script>
  45.  
RAW Paste Data