Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function GetOnlinePlayers($ip, $port = 25565) {
  2. // Create a CURL connection to the API.
  3. $ch = curl_init('https://mcapi.us/server/status?ip='.$ip.'&port='.$port);
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5. $results = curl_exec($ch);
  6. curl_close($ch);
  7.  
  8. // Unserialize the JSON output
  9. $json = json_decode($results, true);
  10.  
  11. // Return the online players
  12. $onlineplayers = $json['players']['now'];
  13. return $onlineplayers;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement