2017 © Pedro Peláez
 

library otinfo

Open Tibia Server Info Parser

image

renatorib/otinfo

Open Tibia Server Info Parser

  • Wednesday, May 27, 2015
  • by renatorib
  • Repository
  • 8 Watchers
  • 15 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

OTServer Info Build Status

Catch information from servers' response by ip and port, (*1)

Install

Just download this repo, and include otinfo.php Important: Must have a writable cache folder in the same level of otinfo.php or will not work correctly, (*2)

include('otinfo.php');

Get started

To instantiate an otserv, create a new Otinfo object, (*3)

$server = new Otinfo\Otinfo('shadowcores.twifysoft.net');

The first parameter is the server $ip, and the second is the $port (defined 7171 as default), (*4)

Get informations, (*5)

if ($server->execute()) {
  echo "Players online: " . $server->players['online'] . "<br />";
  echo "Server location: " . $server->serverinfo['location'] . "<br />";
  echo "Client version: " . $server->serverinfo['client'] . "<br />";
  // these are just a few examples
} else {
  echo "Server offline";
  // if execute() returns false, the server are offline
}

The `execute()' method catch/parse the responses returned by server and return false if server are offline., (*6)

Possible responses

Each server has its own response, and may be different from the others. This means that not all respond with the same information, and a server may have information that others do not have., (*7)

Here are some possible answers nodes * players * serverinfo * motd * owner * monsters * map * npcs * maybe others, (*8)

This means if you want to test, can print_r, var_dump, and whatelse, the nodes to know returned responses, (*9)

print_r($server->players);
print_r($server->serverinfo);
//etc

Cache

Otinfo cache itself not only for performance, but also to avoid empty responses, caused due to the protection of tfs. As said before, you must have a writable cache folder in the same level of otinfo.php or will not work correctly. The time of cache as default 180 seconds (three minutes). May you edit in otinfo.php changing this line, (*10)

private static $cache = 180; //seconds you want

Timeout

When the connection is bad, you can increase the timeout, (*11)

private static $timeout = 5; //seconds you want

Made with :heart: by Renato Ribeiro and Ranieri Althoff, (*12)

Contributors - my heartfelt thanks * gpedro * rmobis * yrpen * DSpeichert, (*13)

The Versions

27/05 2015

dev-master

9999999-dev http://github.com/renatorib/otinfo

Open Tibia Server Info Parser

  Sources   Download

MIT

The Requires

 

tibia opentibia otserv