• 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 --TFS 0.3 rev 906

Ninkobi

Owner /Founder of Syphera
Joined
Apr 5, 2008
Messages
206
Reaction score
1
Location
England
My deathlist does not work properly on tfs rev 906, it jus crashes the server if u die, here is my playerdeath.lua:
Code:
local config = {
	deathListEnabled = getConfigInfo('deathListEnabled'),
	sqlType = getConfigInfo('sqlType'),
	maxDeathRecords = getConfigInfo('maxDeathRecords')
}

function onDeath(cid, corpse, killer)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
	if(config.deathListEnabled == "yes") then
		if(killer ~= FALSE) then
			if(isPlayer(killer) == TRUE) then
				killerName = getPlayerGUID(killer)
			else
				killerName = getCreatureName(killer)
			end
		else
			killerName = "field item"
		end

		db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(killerName) .. ");")
		local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
		if(rows:getID() ~= -1) then
			local deathRecords = rows:numRows(true)
			if(config.sqlType == "sqlite") then
				while(deathRecords > config.maxDeathRecords) do
					db.executeQuery("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
			else
				while(deathRecords > config.maxDeathRecords) do
					db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;")
					deathRecords = deathRecords - 1
				end
			end
		end
	end
end

Here is my database structure for player_deaths:
Code:
CREATE TABLE `player_deaths`
(
	`player_id` INT NOT NULL,
	`time` BIGINT UNSIGNED NOT NULL DEFAULT 0,
	`level` INT NOT NULL DEFAULT 1,
	`killed_by` VARCHAR(255) NOT NULL,
	FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE = InnoDB;
 
Back
Top