<?php // to not repeat all that stuff include_once 'quickstart.php'; $deaths = new OTS_Deaths_List(); $deaths->setLimit(10); foreach ($deaths as $index => $death) { echo "Player " . $death->getPlayer()->getName() . " got killed by "; $kills = $death->getKillsList(); foreach ($kills as $index2 => $kill) { $monsters = $kill->getEnvironments(); foreach ($monsters as $index3 => $monster) { echo $monster . ", "; } $players = $kill->getPlayersList(); foreach ($players as $index3 => $player) { echo $player . ", "; } } echo "<br />"; }
/** * List of character deaths. * * <p> * Note: Returned object is only prepared, but not initialised. When using as parameter in foreach loop it doesn't matter since it will return it's iterator, but if you will wan't to execute direct operation on that object you will need to call {@link OTS_Base_List::rewind() rewind() method} first. * </p> * * @version 0.2.0+SVN * @since 0.2.0+SVN * @return OTS_Deaths_List List of player deaths. * @throws E_OTS_NotLoaded If player is not loaded. */ public function getDeathsList() { if (!isset($this->data['id'])) { throw new E_OTS_NotLoaded(); } // creates filter $filter = new OTS_SQLFilter(); $filter->compareField('player_id', (int) $this->data['id']); // creates list object $list = new OTS_Deaths_List(); $list->setFilter($filter); return $list; }