Hello, I have got problem with player deaths. I'm using TFS 0.3.4.
When player dies, there isn't anything inserting into player_deaths table in database. In case of this there aren't any deaths on my website. What's wrong? Here's my login.lua file:
creaturescripts.xml:
and playerdeath.lua:
I've tried many versions of this playerdeath.lua file and it still won't work... Anybody can help me? Thanks,
Samik
Btw, sorry for my english.
When player dies, there isn't anything inserting into player_deaths table in database. In case of this there aren't any deaths on my website. What's wrong? Here's my login.lua file:
Code:
function onLogin(cid)
registerCreatureEvent(cid, "PlayerDeath")
registerCreatureEvent(cid, "BountyHunter")
registerCreatureEvent(cid, "Inquisition")
return TRUE
end
creaturescripts.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
<event type="kill" name="KilledMonstersCounter" script="monster_counter.lua"/>
<event type="advance" name="Playeradvance" event="script" value="advance.lua"/>
<event type="advance" name="playeradvance" script="advance.lua"/>
<event type="kill" name="PlayerKill" event="script" value="kill.lua"/>
<event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
<event type="receivemail" name="mail" event="script" value="mail.lua"/>
<event type="receivemail" name="Mail" event="script" value="mail.lua"/>
<event type="death" name="Inquisition" script="inquisition.lua"/>
<event type="kill" name="BountyHunter" script="kill.lua"/>
</creaturescripts>
and playerdeath.lua:
Code:
local config = {
deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
sqlType = getConfigInfo('sqlType'),
maxDeathRecords = getConfigInfo('maxDeathRecords')
}
config.sqlType = config.sqlType == "mysql" 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
I've tried many versions of this playerdeath.lua file and it still won't work... Anybody can help me? Thanks,
Samik
Btw, sorry for my english.