Website - Want to check player info?
Hello everyone,
I've just decided to scrap an old project of mine, and I've decided to release a php class I've been using that I've named "Tibia", it allows you to get onlinelist, highscores aswell as specific character info.
http://pastebin.com/xebcWxfp
All I require if you use it is that you credit me, only has to do so in the php file and I would appreciate if you PM me the URL to your site so I could take a look at what creative ideas you've come up with to use this.
Now, onto the usage!
PHP Code:
$tibia = new Tibia;
$chartocheck = "Bubble";
$chardata = $tibia->characterInfo($chartocheck);
print_r($chardata); // Will print all of the data in the returned array.
Want to know who is online in Aurora? Easy!
PHP Code:
$tibia = new Tibia;
$world = 'Aurora';
$whoisonline = $tibia->whoIsOnline($world);
Now, lets get abit more complicated, say you want to get information about EVERY character online on Aurora, you can achive this like so;
PHP Code:
$tibia = new Tibia;
$whoisonline = $tibia->whoIsOnline('Aurora');
foreach($whoisonline as $w)
{
$allcharinfo[$w["name"]] = $tibia->characterInfo($w["name"]);
}
// At this point $allcharinfo contains all data of all online characters on Aurora.
Want to list all worlds that exist on your site? This below example uses a simple database class which is just a abstraction layer of PDO (Php Data Objects
PHP Code:
// Updates Tibia Worlds based on Tibia.com
$tc = new Tibia();
$worlds = $tc->getWorlds();
foreach($worlds as $w){
$name = $w["name"];
$location = $w["location"];
$type = $w["worldtype"];
// Check if world exists, if not add it.
$db->query("SELECT id FROM worlds WHERE name = :name");
$db->bind(":name", $name);
$data = $db->single();
if(empty($data)){ // World doesn't yet exist in database, lets add it!
$db->query("INSERT INTO worlds (name, type, location) VALUES(:name, :type, :location)");
// Bind data
$db->bind(":name", $name);
$db->bind(":type", getWorldType($type));
$db->bind(":location", getLocation($location));
// End bind data
$db->execute();
}
}
I hope this is useful to somebody out there, for example if you're a gold seller you could use this to make sure that when a order is submitted that the character to send the gold to really exists, if not throw a error at the user and make them retype the name.
/Hultin