ond
Veteran OT User
Hello, I have an issue with my website. If, let's say, you die 3 times, then the last death will only be shown.
= Only show one death when you search on the website, for that character. My database store all deaths, so it must be the website's scripts & functions that need to be edited.
Here is
htdocs/class/player.php:
htdocs/characters.php:
If I were unclear what I need help with, just post here and I'll try to explain even better. I would be very glad if someone could help me with this, I think it can help more than me.
Thanks for now!
= Only show one death when you search on the website, for that character. My database store all deaths, so it must be the website's scripts & functions that need to be edited.
Here is
htdocs/class/player.php:
PHP:
private function load_deaths() {
if(empty($this->attrs['id'])) throw new PlayerNotLoadedException();
if($this->sql->isTable('player_deaths')) {
$query = "SELECT * FROM `player_deaths` WHERE (`player_id` = '".$this->sql->quote($this->attrs['id'])."') ORDER BY time DESC LIMIT 10";
$this->sql->myQuery($query);
$i = 0;
while($a = $this->sql->fetch_array()) {
$killer = new Player();
try {
$killer->find($a['lasthit_killer']);
$this->deaths[$i]['killer_name'] = $killer->attrs['name'];
$this->deaths[$i]['killer_id'] = $killer->attrs['id'];
} catch(PlayerNotFoundException $e) {
try {
$killer->load($death['lasthit_killer']);
$this->deaths[$i]['killer_name'] = $killer->attrs['name'];
$this->deaths[$i]['killer_id'] = $killer->attrs['id'];
} catch(PlayerNotFoundException $e) {
$this->deaths[$i]['killer_name'] = $a['lasthit_killer'];
$this->deaths[$i]['killer_id'] = null;
}
}
$this->deaths[$i]['victim_level'] = $a['level'];
$this->deaths[$i]['date'] = $a['time'];
$i++;
}
} else throw new DatabaseException('Deaths data not found in database or it is not compatible.');
return true;
}
htdocs/characters.php:
PHP:
if ($cfg['show_deathlist']) {
if ($player->deaths) {
echo '<b>Latest Deaths</b><br/>';
$prevdate = 0;
foreach ($player->deaths as $death) {
if ($death['killer_id'])
$name = '<a href="characters.php?player_id='.$death['killer_id'].'">'.$death['killer_name'].'</a>';
else
$name = $death['killer_name'];
if($prevdate == $death['date'])
echo ' and by '.$name.'<br/>';
else
echo '<i>'.date("jS F Y H:i:s",$death['date']).'</i> Killed at level '.$death['victim_level'].' by '.$name.'<br/>';
$prevdate = $death['date'];
}
}
}
} catch(PlayerNotFoundException $e) {
echo 'Player not found';
} catch(PlayerException $e) {}
If I were unclear what I need help with, just post here and I'll try to explain even better. I would be very glad if someone could help me with this, I think it can help more than me.
Thanks for now!