Skip to content

Open Tibia Server Info Parser (otinfo). Catch information like players online, owner, motd, map weight, monsters, npcs, etc. passing IP and PORT.

License

Notifications You must be signed in to change notification settings

renatorib/otinfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OTServer Info Build Status

Catch information from servers' response by ip and port

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

include('otinfo.php');

Get started

To instantiate an otserv, create a new Otinfo object

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

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

Get informations

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.

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.

Here are some possible answers nodes

  • players
  • serverinfo
  • motd
  • owner
  • monsters
  • map
  • npcs
  • maybe others

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

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

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

Timeout

When the connection is bad, you can increase the timeout

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

Made with ❤️ by Renato Ribeiro and Ranieri Althoff

Contributors - my heartfelt thanks

  • gpedro
  • rmobis
  • yrpen
  • DSpeichert

About

Open Tibia Server Info Parser (otinfo). Catch information like players online, owner, motd, map weight, monsters, npcs, etc. passing IP and PORT.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages