• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Znote AAC] Last deaths

Raggaer

Godly Member
Joined
Jul 25, 2012
Messages
1,557
Solutions
8
Reaction score
957
Location
Spain
Hello, made this last deaths page for Znote ACC!

- Photo -

Untitled-2.jpg

- Install -

Create a new PHP File in your znote folder
Open it and copy this code
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1>Last deaths</h1>
<?php
	
	$getdeaths = mysql_query("SELECT * FROM player_deaths ORDER BY time DESC LIMIT 10")or die(mysql_error());
	echo '<table border="0">
	<tr class="yellow"><td>Player</td><td>Level</td><td>Killed by</td></tr>';
	while ($showdeaths = mysql_fetch_assoc($getdeaths)) {
	$yd = $showdeaths['player_id'];
	$level = $showdeaths['level'];
	$player = $showdeaths['is_player'];
	$killedby = $showdeaths['killed_by'];
	$getname = mysql_query("SELECT name FROM players WHERE id = '$yd'");
	while ($parse = mysql_fetch_assoc($getname)) {
	$name = $parse['name'];
	echo '<tr><td>';
	echo '<a href="characterprofile.php?name='.$name.'">'.$name.'</a>';
	echo '</td><td>';
	echo $level;
	echo '</td><td>';
	if ($player == 1) {
		echo '<a href="characterprofile.php?name='.$killedby .'">'.$killedby.'</a> ( PVP )';
	} else {
	echo $killedby;
	}
	echo '</td></tr>';
	}
	}
	echo '</table>';
?>
<?php include 'layout/overall/footer.php'; ?>

Enjoy :-3
 
Thanks for your contribution. :)

Keep in mind this is only compatible with TFS 0.2.

@Tip: Raggaer:
PHP:
if ($config['TFSVersion'] == 'TFS_02') {
	// TFS 0.2 code here
} else if ($config['TFSVersion'] == 'TFS_03') {
	// TFS 0.3 code here
}

The queries are a bit different (and more complicated) on TFS 0.3.

Here is how I fetched a players death list in TFS 0.3:

fetch deathlist --> fetch killer id based on deathlist --> try to fetch player id based on killer id (true, done. False then - fetch monster name from killer id).
Functions from users.php:
PHP:
// TFS .3 compatibility
function user_fetch_deathlist03($char_id) {
	$char_id = (int)$char_id;
	$query = mysql_query("SELECT * FROM `player_deaths` WHERE `player_id`='$char_id' order by `date` DESC LIMIT 0, 10") or die(mysql_error());
	while($row = mysql_fetch_assoc($query)) {
		$row['time'] = $row['date'];
		$array[] = $row;
	} 
	return !empty($array) ? $array : false;
}
// same
function user_get_kid($did) {
	$did = (int)$did;
	return mysql_result(mysql_query("SELECT `id` FROM `killers` WHERE `death_id`='$did';"), 0, 'id');
}
// same
function user_get_killer_id($kn) {
	$kn = (int)$kn;
	return mysql_result(mysql_query("SELECT `player_id` FROM `player_killers` WHERE `kill_id`='$kn';"), 0, 'player_id');
}
// same
function user_get_killer_m_name($mn) {
	$mn = (int)$mn;
	return mysql_result(mysql_query("SELECT `name` FROM `environment_killers` WHERE `kill_id`='$mn';"), 0, 'name');
}

Its messy code, I still got alot of optimizations I need to do on Znote AAC. :p
 
Last edited:
Well for TFS_03 maybe just ORDER BY date no? didnt test it, forgot to say this just supports TFS_0.2 if anyone needs helps to use it with 0.3 just say it
 
Try the one znote wrote im lazy to pass it to TFS_03 xD
 
why in localhost/deaths.php don't work, :
HuN8-i2.png

Killed by .. ???????????
and on see a character yes d:
[09 September 2012 (02:07)] Killed at level 567 by player: Falconne
 
Do not work, lot of errors

- - - Updated - - -

Code:
Notice: Undefined index: is_player in C:\xampp\htdocs\deaths.php on line 12

Notice: Undefined index: killed_by in C:\xampp\htdocs\deaths.php on line 13
 
Hello guys!
Modded this to work on 0.3, please excuse me for messy code - but it works:

First add a function to engine/function/users.php ( I couldnt find this specific function anywhere, please refer to the right one if im wrong Znote, so I made a new):
PHP:
function user_name($id) { //USERNAME FROM PLAYER ID
	$id= sanitize($id);
	return mysql_result(mysql_query("SELECT `name` FROM `players` WHERE `id`='$id';"), 0, 'name');
}


Then in your deathlist.php, where you want it listed:
PHP:
<?php 
     
    $getdeaths = mysql_query("SELECT * FROM player_deaths ORDER BY date DESC LIMIT 40")or die(mysql_error()); 
    echo '<table border="0"> 
    <tr class="yellow"><td>Player</td><td>Level</td><td>Killed by</td></tr>'; 
    while ($showdeaths = mysql_fetch_assoc($getdeaths)) { 
		$yd = $showdeaths['player_id']; 
		$level = $showdeaths['level']; 
		$kid = user_get_kid($showdeaths['id']);
			if (user_get_killer_id($kid)) {
				$player = 1;
				$killedby = user_name(user_get_killer_id($kid));
			}
			else {
				$killedby = user_get_killer_m_name($kid);
				$player = 0;
			}
		$getname = mysql_query("SELECT name FROM players WHERE id = '$yd'"); 
			while ($parse = mysql_fetch_assoc($getname)) { 
				$name = $parse['name']; 
				echo '<tr><td>'; 
				echo '<a href="characterprofile.php?name='.$name.'">'.$name.'</a>'; 
				echo '</td><td>'; 
				echo $level; 
				echo '</td><td>'; 
					if ($player) { 
						echo '<a href="characterprofile.php?name='.$killedby .'">'.$killedby.'</a>'; 
					} else echo $killedby; 
			} 
		echo '</td></tr>'; 
    } 
 echo '</table>'; 
 ?>
 
Do not work, lot of errors

- - - Updated - - -

Code:
Notice: Undefined index: is_player in C:\xampp\htdocs\deaths.php on line 12

Notice: Undefined index: killed_by in C:\xampp\htdocs\deaths.php on line 13

Im not getting those errors u maybe using tfs 0.3
 
Hello guys!
Modded this to work on 0.3, please excuse me for messy code - but it works:

First add a function to engine/function/users.php ( I couldnt find this specific function anywhere, please refer to the right one if im wrong Znote, so I made a new):

I made a flexible function to fetch information from players table.

PHP:
<?php
// Select which parameters you want, this example: fetch player name and vocation from players table (based on player id).
$data = user_character_data($charid, 'name', 'vocation');

echo $data['name']; // Result: playername
echo $data['vocation'] // Result: 1 (if its a sorcerer, etc...).
?>
 
Back
Top