protected function _initWowlib() { // Include the wowlib file require path(ROOT, 'third_party', 'wowlib', 'Wowlib.php'); // Add Trace \Debug::trace('Initializing Wowlib...', __FILE__, __LINE__); // Try to init the wowlib try { \Wowlib::Init(config('emulator')); \Debug::trace('Wowlib Initialized successfully', __FILE__, __LINE__); } catch (Exception $e) { \Debug::silent_mode(false); \Debug::trace('Wowlib failed to initialize. Message thrown was: ' . $e->getMessage(), __FILE__, __LINE__); show_error('Wowlib Error: ' . $e->getMessage(), false, E_ERROR); } }
/* | -------------------------------------------------------------- | This example shows you how to load a realm, and fetch an account | -------------------------------------------------------------- */ // Include the wowlib class include 'Wowlib.php'; // Init the wowlib Wowlib::Init($emulator); // Fetch realm, and Dump the account id of 5 $Realm = Wowlib::getRealm('myrealmid', $connA); $Account = $Realm->fetchAccount($accountId); echo "This account username for account id {$accountId} is " . $Account->getUsername(); /* | -------------------------------------------------------------- | In this next example, Lets fetch a character | -------------------------------------------------------------- */ // Load a driver first, which ever is most compatible with your core revision // We will skip the world data connection by placing null as the 3rd param $Driver = Wowlib::load('_default', $connC, null); // The driver... Each method under the driver object, is a class that is loacated // inside the loaded driver folder "drivers/$emulator/_default" in this case $Character = $Driver->characters->fetch(2); if (is_object($Character)) { echo "<br /><br />This character's name is " . $Character->getName() . " and he is level " . $Character->getLevel() . "!"; } else { echo "<br /><br />Character Doesnt Exist :O"; } // Echo benchmark time echo "<br /><br />Rendered in " . round(microtime(1) - $start, 4) . " seconds";
public static function setEmulator($emu) { // Make sure we are loaded here! if (!self::$initilized) { throw new Exception('Cannot load driver, Wowlib was never initialized!', 1); } // List all the drivres in the emulator folder. if (!in_array($emu, self::$emulators)) { return false; } self::$emulator = $emu; return true; }