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

Lua solved

Status
Not open for further replies.

tompan

Member
Joined
Dec 13, 2008
Messages
646
Reaction score
24
Location
Sweden
Well my death list wont work, i found out that in creaturescripts.xml that it didnt have the line
<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
so i edit it in there.
but still it wont save deaths in my table player_deaths
i have in my config
Code:
	-- Deathlist
	deathListEnabled = true
	maxDeathRecords = 5

and i dont know if it is the playerdeath.lua thats not right.


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 == "TRUE") 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

db table
Code:
(
	`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;

if anyone have any idea about this try help me out!
 
Last edited:
Code:
[COLOR="#FF0000"]-	if(config.deathListEnabled == "TRUE") then[/COLOR]
[COLOR="#006400"]+	if(config.deathListEnabled) then[/COLOR]
 
I know u use avesta, so search for this line in ur config.lua
Code:
StorePlayerDeaths = true

and if it's true then it will store player deaths;)

king regards jeffry,
 
Status
Not open for further replies.
Back
Top