local config = {
deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
sqlType = getConfigInfo('sqlType'),
maxDeathRecords = getConfigInfo('maxDeathRecords')
,
fPos = {x=175, y=128, z=8},
tPos = {x=186, y=128, z=8}
}
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if isInArea(getCreaturePosition(cid), config.fPos, config.tPos) then
reset1()
end
if getPlayerItemCount(cid, 2173) >= 1 then
doPlayerRemoveItem(cid, 2173, 1)
end
if(config.deathListEnabled == TRUE) then
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 == "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
end
local monsterArea = {
fromPos = {x=176, y=128, z=8},
toPos = {x=186, y=128, z=8}
}
local removeWalls = {
{x=174, y=128, z=8, stackpos=1},
{x=188, y=128, z=8, stackpos=1},
{x=173, y=128, z=8, stackpos=1}
}
local itemId = 1304
local createWalls = {
{x=175, y=128, z=8},
{x=186, y=128, z=8},
{x=187, y=128, z=8}
}
function reset1()
for _, pos in ipairs(removeWalls) do
local thing = getThingfromPos(pos)
if(thing.uid > 0) then
doRemoveItem(thing.uid)
end
end
for _, pos in ipairs(createWalls) do
doCreateItem(itemId, 1, pos)
end
for _, thing in mapArea(monsterArea.fromPos, monsterArea.toPos, STACKPOS_TOP_CREATURE) do
if(isMonster(thing.uid) == TRUE)then
doRemoveCreature(thing.uid)
end
end
return TRUE
end
function mapArea(fromPos, toPos, stack)
-- Area iterator by Colandus @ OTFans.net
local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
return function()
if (pos.y < toPos.y) then
pos.y = pos.y+1
elseif (pos.x <= toPos.x) then
pos.y = fromPos.y
pos.x = pos.x+1
else
pos.x = fromPos.x
pos.y = fromPos.y
pos.z = pos.z+1
end
if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
if (stack == nil) then
return pos
else
pos.stackpos = stack
return pos, getThingfromPos(pos)
end
end
end
end