Hello.
First of all im using TFS 0.2 8,4. btw im using Geisor Acc manager.
And the second is that my deathlist aint working,wondring if somone here maybe know why.
This happends when somone dies.
Here is the error's
Here is my script.
Thank you,
Your's
Dalale
First of all im using TFS 0.2 8,4. btw im using Geisor Acc manager.
And the second is that my deathlist aint working,wondring if somone here maybe know why.
This happends when somone dies.
Here is the error's
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/playerdeath.lua:onDeath
data/creaturescripts/scripts/playerdeath.lua:36: attempt to index global 'db' (a nil value)
stack traceback:
data/creaturescripts/scripts/playerdeath.lua:36: in function <data/creaturescripts/scripts/playerdeath.lua:3>
Here is my script.
Code:
dofile("./config.lua")
function onDeath(cid, corpse, killer)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
if isPlayer(killer) == TRUE then
local levelDiff = getPlayerLevel(cid) - getPlayerLevel(killer)
if (getPlayerLevel(cid) >= 200 or levelDiff >= 50) then
local item = doPlayerAddItem(killer, 8698, 1)
doSetItemSpecialDescription(item, "It's a trohpy " .. getCreatureName(killer) .. " [" .. getPlayerLevel(killer) .. "] gained for killing " .. getCreatureName(cid) .. " [" .. getPlayerLevel(cid) .. "].")
broadcastMessage(getCreatureName(cid) .. " [" .. getPlayerLevel(cid) .. "] just got slayed by " .. getCreatureName(killer) .. " [" .. getPlayerLevel(killer) .. "]!", MESSAGE_STATUS_WARNING)
local maxMoney = levelDiff * math.random(1, 10000)
local money = math.min(maxMoney, getPlayerMoney(cid))
if money > 0 then
doPlayerRemoveMoney(cid, money)
doPlayerAddMoney(killer, money)
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_RED, "You gained " .. money .. " gold coins for killing " .. getCreatureName(cid) .. ".")
end
end
end
if 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
Thank you,
Your's
Dalale