• 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!

Death List wont record

Massmurdera

New Member
Joined
Jul 24, 2009
Messages
19
Reaction score
0
When a player dies it doesnt record who or what he was killed by heres my scripts...

data\creaturescripts\scripts\playerdeath.lua


Code:
dofile("./config.lua")

function onDeath(cid, corpse, killer)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
	if deathListEnabled == "yes" then
		if sqlType == "mysql" then
			env = assert(luasql.mysql())
			con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
		else -- sqlite
			env = assert(luasql.sqlite3())
			con = assert(env:connect(sqliteDatabase))
		end
		local byPlayer = FALSE
		if killer == FALSE then
			killerName = "field item"
		else
			if isPlayer(killer) == TRUE then
				byPlayer = TRUE
			end
			killerName = getCreatureName(killer)
		end
		assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");"))
		local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";"))
		local deathRecords = numRows(cursor)
		if sqlType == "mysql" then
			while deathRecords > maxDeathRecords do
				delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;"))
				deathRecords = deathRecords - 1
			end
		else
			while deathRecords > maxDeathRecords do
				delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);"))
				deathRecords = deathRecords - 1
			end
		end			
		con:close()
		env:close()
	end
end

data\creaturescripts\creaturescripts.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
	<event type="login" name="PlayerLogin" script="login.lua"/>
	<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
	<event type="death" name="DeathBroadcast" script="deathBroadcast.lua"/>
	<event type="logout" name="logout" event="script" value="logout.lua"/>
</creaturescripts>

and also i want it to be shown on my website, but since there is no records it says that no one has ever died...

killstatistics.php

Code:
<?PHP
$players_deaths_data = $SQL->query('SELECT * FROM players,player_deaths WHERE players.id = player_deaths.player_id ORDER BY time DESC LIMIT '.$config['site']['last_deaths_limit']);
$number_of_players_deaths = 0;
if(!empty($players_deaths_data)) {
$vowels = array("e", "y", "u", "i", "o", "a");
foreach($players_deaths_data as $dead) {
	$number_of_players_deaths++;
	if(is_int($number_of_players_deaths / 2)) {
		$bgcolor = $config['site']['darkborder'];
	}
	else
	{
		$bgcolor = $config['site']['lightborder'];
	}
	$players_rows .= '<TR BGCOLOR="'.$bgcolor.'"><TD WIDTH="30"><center>'.$number_of_players_deaths.'.</<center></TD><TD><a href="index.php?subtopic=characters&name='.$dead['name'].'"><b>'.$dead['name'].'</b></a> killed at level <b>'.$dead['level'].'</b> by ';
	if($dead['is_player'] == 1) {
	$players_rows .= '<a href="index.php?subtopic=characters&name='.$dead['killed_by'].'"><b>'.$dead['killed_by'].'</b></a>';
	}
	else
	{
		if($dead['killed_by'] == "-1")
		{
			$players_rows .= "item or field";
		}
		else
		{
			if(in_array(substr(strtolower($dead['killed_by']), 0, 1), $vowels))
			{
				$players_rows .= "an ";
			}
			else
			{
				$players_rows .= "a ";
			}
			$players_rows .= $dead['killed_by'];
		}
	}
	$players_rows .= '.</TD></TR>';
}
}
if($number_of_players_deaths == 0) {
	//server status - server empty
	$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><B>Last Deaths</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1><TR><TD>No one died on '.$config['server']['serverName'].'.</TD></TR></TABLE></TD></TR></TABLE><BR>';
}
else
{
	//server status - someone is online
	$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><B>Last Deaths</B></TD></TR></TABLE>';
	//list of players
	$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>'.$players_rows.'</TABLE>';
}
?>
 
Back
Top