Exemple #1
0
<?php

// includes POT main file
include_once 'classes/OTS.php';
// dont use POT::getInstance() anymore
// connects to database
POT::connect(POT::DB_MYSQL, array('host' => 'localhost', 'user' => 'wrzasq', 'database' => 'otserv'));
// load all resources
POT::loadVocations('/home/wrzasq/.otserv/data/vocations.xml');
POT::loadMonsters('/home/wrzasq/.otserv/data/monster/');
POT::loadSpells('/home/wrzasq/.otserv/data/spells/spells.xml');
POT::loadItems('/home/wrzasq/.otserv/data/items/');
POT::loadMap('/home/wrzasq/.otserv/data/world/map.otbm');
/*
    Invites handling driver.
*/
class InvitesDriver implements IOTS_GuildAction
{
}
/*
    Membership requests handling driver.
*/
class RequestsDriver implements IOTS_GuildAction
{
}
/*
    Standard binary format cache.
*/
class FileCache implements IOTS_FileCache
{
}
Exemple #2
0
<?php

// to not repeat all that stuff
include 'quickstart.php';
// loads item typing information
// dont use POT::getInstance() anymore
POT::loadItems('/path/to/your/ots/data/items');
// creates new player object
$player = new OTS_Player();
$player->find('Wrzasq');
/*
    Items loading example.
*/
// loading item from ammunition slot
$item = $player->getSlot(POT::SLOT_AMMO);
echo $player->getName(), ' has item with id ', $item->getId(), ' in his/her ammo slot.', "\n";
// checks if item is a container
if ($item instanceof OTS_Container) {
    // list backpack content
    foreach ($item as $inside) {
        echo 'Container contains item with id ', $inside->getId(), '.', "\n";
    }
}
/*
    Items tree composing example.
*/
// creates container - here it would be a depot locker (we pass ID of item to create)
$container = new OTS_Container(2590);
// now let's create depot chest
$chest = new OTS_Container(2594);
// let's put chest inside locker
 /**
  * Fetch an item color from cache or OTB.
  *
  * @param $itemid
  * @return false|array RGB
  */
 public static function itemColor($itemid)
 {
     if (!isset(self::$items[$itemid])) {
         if (!\POT::areItemsLoaded()) {
             \POT::loadItems(public_path() . '/xml');
         }
         $list = \POT::getItemsList();
         if ($list->hasItemTypeId($itemid)) {
             $item = $list->getItemType($itemid);
             if ($item->hasAttribute('minimapColor')) {
                 self::$items[$itemid] = self::$rgbs[$item->getAttribute('minimapColor')];
             }
         }
         if (!isset(self::$items[$itemid])) {
             self::$items[$itemid] = false;
         }
     }
     return self::$items[$itemid];
 }