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

Windows Player deaths not working in 0.2.8

eloth

Member
Joined
Apr 6, 2013
Messages
29
Reaction score
5
Hello,
I guess the table player_deaths not working, or script. When player died in my server nothing changed into the table, somebody know what's wrong?

There is not written "You are ded." when player died.



playerdeath.lua
Code:
function onDeath(cid, corpse, killer)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
    dofile("./config.lua")
    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
        local killerName = escapeString(getCreatureName(killer))
        if isPlayer(killer) == TRUE then
            byPlayer = TRUE
        elseif isPlayer(killer) ~= FALSE then
            killerName = "field item"
        end
        query = assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUIDByName(getCreatureName(cid)) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. killerName .. "', " .. byPlayer .. ");"))
        local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ";"))
        local deathRecords = numRows(cursor)
        while deathRecords > maxDeathRecords do
            delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. " ORDER BY `time` LIMIT 1;"))
            deathRecords = deathRecords - 1
        end
        con:close()
        env:close()
    end
end

login
Code:
    registerCreatureEvent(cid, "PlayerDeath")

Creaturescripts.xml
Code:
    <event type="death" name="PlayerDeath" script="playerdeath.lua"/>


thanks!
 
Do you get errors in your console? Is the creaturescripts.xml line maybe added as a comment (with <!-- and -->)?
 
Back
Top