Signup Now
Results 1 to 6 of 6
  1. #1
    Banned
    Join Date
    Feb 2014
    Location
    Leetstreet
    Posts
    324
    Reputation
    38
    Rep Power
    0

    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
    Last edited by Hultin; 02-23-2014 at 02:25 PM.

  2. #2
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,441
    Reputation
    309
    Rep Power
    28
    Cool stuff, mate. I only missed the possibility of parsing both character's info and deaths with a single request.

    If anyone is interested, this might come in hand as well:

    https://github.com/rmobis/tmw/blob/m...terUpdater.php

    It's an old as fuck project, but who knows.

  3. #3
    Banned
    Join Date
    Feb 2014
    Location
    Leetstreet
    Posts
    324
    Reputation
    38
    Rep Power
    0
    It wouldn't be to difficult to add that into characterInfo() function, I didn't have a need for that data for the project I scrapped but if there's more people who'd like I will definatly add such a functionality (probably as a optional parameter)

    Infact, it's simple as this;
    PHP Code:
                $ret[] = array(
                    
    "name"      =>  $name,
                    
    "level"     =>  $level,
                    
    "vocation"  =>  $vocation,
                    
    "deaths" => $this->characterDeaths($name)
                ); 
    Line 134 - for all chars on a world, keep in mind however that this will increase your serverload noticably, as it means one more pagerequest for each character online!

    Or;

    PHP Code:
    $character["deaths"] = $this->characterDeaths($name); 
    anywhere inside the characterInfo() function.

    Note that $this means that you are INSIDE the class, if you use this code anywhere else replace it with whatever you name the variable you put the Tibia object inside.
    Last edited by Hultin; 02-22-2014 at 10:33 PM.

  4. #4
    Wind Powered
    Join Date
    Dec 2013
    Location
    dvscripts.com
    Posts
    7,105
    Reputation
    433
    Rep Power
    39
    any way to make hunted list of enemy with this files?

  5. #5
    Banned
    Join Date
    Feb 2014
    Location
    Leetstreet
    Posts
    324
    Reputation
    38
    Rep Power
    0
    It is indeed possible, it's quite simple aswell! The example below will use an array to determine what characters to look for, you could however use a textfield/textarea and use the native function explode() to achieve the same via $_POST[] data.

    This code is, however, untested so if it throws you an error, let me know. Also you need to include the Tibiaparser.
    PHP Code:
    <?php
    $characters 
    = array("Bubble""Eternal Oblivion");
    $tibia = new Tibia;

    $online_data = array();

    foreach(
    $characters as $c){
        
    $data $tibia->characterInfo($c);
        if(!isset(
    $online_data[$data["world"]])){
            
    // We store all characters per world so we only need to request each world once per pageload.
            
    $online_data[$data["world"]] = $tibia->whoIsOnline($data["world"]);
        }
        
    $online_chars[$c] = in_array($c$online_data[$data["world"]]);
    }

    print_r($online_chars);
    Will print true or false, the array keys of $online_chars is the charactername. True = online, false = offline (or rather, not found in onlinelist)
    Last edited by Hultin; 02-22-2014 at 10:32 PM.

  6. #6
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,441
    Reputation
    309
    Rep Power
    28
    Quote Originally Posted by Hultin View Post
    It wouldn't be to difficult to add that into characterInfo() function, I didn't have a need for that data for the project I scrapped but if there's more people who'd like I will definatly add such a functionality (probably as a optional parameter)

    Infact, it's simple as this;
    PHP Code:
                $ret[] = array(
                    
    "name"      =>  $name,
                    
    "level"     =>  $level,
                    
    "vocation"  =>  $vocation,
                    
    "deaths" => $this->characterDeaths($name)
                ); 
    Line 134 - for all chars on a world, keep in mind however that this will increase your serverload noticably, as it means one more pagerequest for each character online!

    Or;

    PHP Code:
    $character["deaths"] = $this->characterDeaths($name); 
    anywhere inside the characterInfo() function.

    Note that $this means that you are INSIDE the class, if you use this code anywhere else replace it with whatever you name the variable you put the Tibia object inside.
    Oh, I meant a single HTTP request. Meaning it would use the same parsed DOM for both deaths and info.

    Quote Originally Posted by Dworak View Post
    any way to make hunted list of enemy with this files?
    If you really are interested in that, you may want to pay a visit to the link I posted above.
    It is a project for a hunted list, "usable" I'd say.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •