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

playerdeath

Ussef

New Member
Joined
May 27, 2009
Messages
123
Reaction score
2
i need some help! im using a 9.10 server! when someone dies it gets me this error >> Lua Script Error: [CreatureScript Interface]

data/creaturescripts/scripts/playerdeath.lua:eek:nDeath
data/creaturescripts/scripts/playerdeath.lua:10: attempt to call field 'sqlite3'
<a nil value>
stack traceback:
[C]: in function 'sqlite3'
data/creaturescripts/scripts/playerdeath.lua:10 in function <data/creat
urescripts/scripts/playerdeath.lua:3>

well thats it! and also it sometimes crashes the server! so please heeeelp!
 
try this
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
 
nope it gives me this error! Warning: [Event::checkScript] Can not load script. /scripts/playerdeath.lua
data/creaturescripts/scripts/playerdeath.lua:2: unexpected symbol near '/'
 
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

this then
 
nope :( still doesnt work says it cant find getbooleanFromString.. in global.. hope u can give me another one if u cant thanks for trying
 
Lua:
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 and "true" or "false") .. ");"))
		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

Lua:
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
any of these?

what server do you use?
 
Last edited:
Back
Top