• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

error in playerdeath.lua

Indenpedens

Banned User
Joined
Nov 6, 2010
Messages
584
Reaction score
39
Location
Poland
Hello guys
i have error:
Code:
[01/07/2012 00:06:27] Lua Script Error: [CreatureScript Interface] 
[01/07/2012 00:06:27] data/creaturescripts/scripts/playerdeath.lua:onDeath

[01/07/2012 00:06:27] luaGetCreatureName(). Creature not found

[01/07/2012 00:06:27] Lua Script Error: [CreatureScript Interface] 
[01/07/2012 00:06:27] data/creaturescripts/scripts/playerdeath.lua:onDeath

[01/07/2012 00:06:27] luaGetCreatureName(). Creature not found

[01/07/2012 00:06:27] Lua Script Error: [CreatureScript Interface] 
[01/07/2012 00:06:27] data/creaturescripts/scripts/playerdeath.lua:onDeath

[01/07/2012 00:06:27] data/creaturescripts/scripts/playerdeath.lua:34: attempt to concatenate local 'damageKillerName' (a boolean value)
[01/07/2012 00:06:27] stack traceback:
[01/07/2012 00:06:27] 	data/creaturescripts/scripts/playerdeath.lua:34: in function <data/creaturescripts/scripts/playerdeath.lua:9>
How to fix it?

distro 0.3.4pl2

rep++
 
LUA:
local config = {
	deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
	sqlType = getConfigInfo('sqlType'),
	maxDeathRecords = getConfigInfo('maxDeathRecords')
}

config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL

function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
	if(config.deathListEnabled ~= TRUE) then
		return
	end

	local hitKillerName = "field item"
	local damageKillerName = ""
	if(lastHitKiller ~= FALSE) then
		if(isPlayer(lastHitKiller) == TRUE) then
			hitKillerName = getPlayerGUID(lastHitKiller)
		else
			hitKillerName = getCreatureName(lastHitKiller)
		end

		if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
			if(isPlayer(mostDamageKiller) == TRUE) then
				damageKillerName = getPlayerGUID(mostDamageKiller)
			else
				damageKillerName = getCreatureName(mostDamageKiller)
			end
		end
	end

	db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
	local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
	if(rows:getID() ~= -1) then
		local amount = rows:getRows(true) - config.maxDeathRecords
		if(amount > 0) then
			if(config.sqlType == DATABASE_ENGINE_SQLITE) then
				for i = 1, amount do
					db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
				end
			else
				db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
			end
		end
	end
end

just a random one :D
 
Back
Top