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

Deathlist.

enriel

Big L
Joined
Dec 14, 2007
Messages
1,254
Reaction score
2
Location
Montenegro
The Deathlist ain't working on the newest TFS that's been released, anyone know how to fix this ?
 
Could you explain more? Is like that you cant make it work with nicaw online acc or?

All I did to show deathlist for TFS is: Find it in characters.php.

Code:
	if ($cfg['show_deathlist']){
		$deaths = $player->getDeaths();
		if ($deaths !== false && !empty($deaths)){
		echo '<b>Deaths</b><br/>';
			foreach ($deaths as $death){
				$killer = new Player($death['killer']);
				
$host = 'localhost';
$usern = 'root';
$password = 'password'; 
$database = 'theforgottenserver'; 
$con = mysql_connect("$host","$usern","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$killa = $death['killer'];
mysql_select_db("$database", $con);
$query = "SELECT name FROM players WHERE name='$killa'";
$query = mysql_query($query);
$query = mysql_fetch_array($query);
if ($query)
$name = '<a href="characters.php?player_name='.$death['killer'].'">'.$death['killer'].'</a>';
else
$name = $death['killer'];
echo '<i>'.date("jS F Y H:i:s",$death['date']).'</i> Killed at level '.$death['level'].' by '.$name.'<br/>';
mysql_close($con);
}
}else{
echo "No deaths found."; 
	
		}
	}

An easy online list could go like...

Code:
$host = 'localhost';
$usern = 'root';
$password = 'password'; 
$database = 'theforgottenserver'; 
$con = mysql_connect("$host","$usern","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$database", $con);
$query = "SELECT name FROM players WHERE online='1' AND group_id='1' OR online='1' AND group_id='2' ORDER BY name ASC";
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows == '0'){
echo "No players online.";}
else{

while($row = mysql_fetch_array($query)){
$name = $row['name'];

echo "<a href='characters.php?player_name=$name'>$name</a><br />";
}
}

Small edit in characters.php to show online or lastlogin:

Replace
Code:
echo "<b>Last Login:</b> ".$lastlogin."<br/>\n";

With
Code:
$host = 'localhost';
$usern = 'root';
$password = 'password'; 
$database = 'theforgottenserver'; 
$con = mysql_connect("$host","$usern","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$database", $con);
$playername = $player->getAttr('name');
$query = "SELECT online FROM players WHERE name='$playername'";
$query = mysql_query($query);
$query = mysql_fetch_row($query);

if ($query[0] == '1'){
echo "<font color=green><b>Online</b></font><br/>\n";
}else{
echo "<b>Last Login:</b> ".$lastlogin."<br/>\n";}
 
Last edited:
No, I meant.. when a player dies it doesn't show on the site or if you write
!deathlist "PLAYERNAME
it says no deaths, I guess latest TFS is bugged or?
 
Can you show me that talkaction?

It havent worked on earlier versions have it? I think there are some unfinished stuff in 0.2 series that will be released in the 0.3 series :p
 
Code:
dofile("./config.lua")

function onSay(cid, words, param)
	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 cur = assert(con:execute("SELECT `name`, `id` FROM `players` WHERE `name` = '" .. escapeString(param) .. "';"))
	local row = cur:fetch({}, "a")
	cur:close()
	if row ~= nil then
		local targetName = row.name
		local targetGUID = row.id
		local str = ""
		local breakline = ""
		for time, level, killed_by, is_player in rows(con, "SELECT `time`, `level`, `killed_by`, `is_player` FROM `player_deaths` WHERE `player_id` = " .. targetGUID .. " ORDER BY `time` DESC;") do
			if str ~= "" then
				breakline = "\n"
			end
			local date = os.date("*t", time)

			local article = ""
			if tonumber(is_player) ~= TRUE then
				killed_by = string.lower(killed_by)
				article = getArticle(killed_by) .. " "
			end

			if date.day < 10 then	date.day = "0" .. date.day	end
			if date.hour < 10 then	date.hour = "0" .. date.hour	end
			if date.min < 10 then	date.min = "0" .. date.min	end
			if date.sec < 10 then	date.sec = "0" .. date.sec	end
			str = str .. breakline .. " " .. date.day .. getMonthDayEnding(date.day) .. " " .. getMonthString(date.month) .. " " .. date.year .. " " .. date.hour .. ":" .. date.min .. ":" .. date.sec .. "   Died at Level " .. level .. " by " .. article .. killed_by .. "."
		end
		if str == "" then
			str = "No deaths."
		end
		doPlayerPopupFYI(cid, "Deathlist for player, " .. targetName .. ".\n\n" .. str)
	else
		doPlayerSendCancel(cid, "A player with that name does not exist.")
	end
	con:close()
	env:close()
end
 
Maybe it was compiled without luaSQL, lol?

I downloaded the TFS Taruntalen ~~ posted.

This is really important, anyone els that has this bug or can help me?

I'm sorry for dubbel spam, but this bug is annoying. Anyone that can help me?
 
Last edited by a moderator:
Try use this playerdeath.lua script (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
 
So I don't have to create a new theard..
well, when I use /closeserver I get a "don't send error".. .. and many players are loosing their houses, how to fix this?
 
Try use this playerdeath.lua script (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

don't work.

"[16/05/2008 16:28:35] Warning: [Event::loadScript] Event onSay not found. data/talkactions/scripts/deathlist.lua"

Learn to read, aye?

++ Check your config.lua if the deathlist is enabled.
 
Back
Top