• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Need change/fix the script of Deathlist

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Hi,

About that command: /deathlist nome of player

By using this command you receive a message on the screen with the deaths of players. But when the message of deaths pass the limit of screen this message is no longer displayed in the game for players.

How I do to fix this to message appear in Default? As any message, but in a form listing. Its possible?

And sorry, I cant do that alone.

Script talkaction deathlist
PHP:
local config = {
    deathAssistCount = getConfigValue('deathAssistCount') + 1,
    maxDeathRecords = getConfigValue('maxDeathRecords'),
    limit = ""
}
if(config.deathAssistCount > 0) then
    config.limit = " LIMIT 0, " .. config.deathAssistCount
end

function onSay(cid, words, param, channel)
    local target = db.getResult("SELECT `name`, `id` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";")
    if(target:getID() == -1) then
        doPlayerSendCancel(cid, "A player with that name does not exist.")
        return true
    end

    local targetName, targetId = target:getDataString("name"), target:getDataInt("id")
    target:free()

    local str, deaths = "", db.getResult("SELECT `id`, `date`, `level` FROM `player_deaths` WHERE `player_id` = " .. targetId .." ORDER BY `date` DESC LIMIT 0, " .. config.maxDeathRecords)
    if(deaths:getID() ~= -1) then
        repeat
            local killers = db.getResult("SELECT environment_killers.name AS monster_name, players.name AS player_name FROM killers LEFT JOIN environment_killers ON killers.id = environment_killers.kill_id LEFT JOIN player_killers ON killers.id = player_killers.kill_id LEFT JOIN players ON players.id = player_killers.player_id WHERE killers.death_id = " .. deaths:getDataInt("id") .. " ORDER BY killers.final_hit DESC, killers.id ASC" .. config.limit)
            if(killers:getID() ~= -1) then
                if(str ~= "") then
                    str = str .. "\n" .. os.date("%d %B %Y %X ", deaths:getDataLong("date"))
                else
                    str = os.date("%d %B %Y %X ", deaths:getDataLong("date"))
                end

                local count, i = killers:getRows(false), 0
                repeat
                    local monster = killers:getDataString("monster_name")
                    if(i == 0 or i == (count - 1)) then
                        monster = string.gsub(monster:gsub("an ", ""), "a ", "")
                    end

                    if(killers:getDataString("player_name") ~= "") then
                        if(i == 0) then
                            str = str .. "Killed at level " .. deaths:getDataInt("level") .. " by:\n  "
                        elseif(i == count) then
                            str = str .. " and by "
                        elseif(i % 4 == 0) then
                            str = str .. ",\n  "
                        else
                            str = str .. ", "
                        end

                        if(monster ~= "") then
                            str = str .. monster .. " summoned by "
                        end

                        str = str .. killers:getDataString("player_name")
                    else
                        if(i == 0) then
                            str = str .. "Died at level " .. deaths:getDataInt("level") .. " by:\n  "
                        elseif(i == count) then
                            str = str .. " and by "
                        elseif(i % 4 == 0) then
                            str = str .. ",\n  "
                        else
                            str = str .. ", "
                        end

                        str = str .. monster
                    end

                    i = i + 1
                    if(i == count) then
                        str = str .. "."
                    end
                until not(killers:next())
                killers:free()
            end
        until not(deaths:next())
        deaths:free()
    else
        str = "No deaths recorded."
    end

    doPlayerPopupFYI(cid, "Deathlist for player: " .. targetName .. ".\n\n" .. str)
    return true
end
 
How many deaths does this character have? Already tried to set the maxDeathRecords lower and see if the client is still crashing?

He have exactly 180 deaths and my config.lua are configured from 100 deaths.

So, I asked if there was a limit. :p

N' i dont get any error in console, this the debug :s
 
use this its work fine with me if u need
Code:
limit = 10
function onSay(cid, words, param, channel)
str = ""
if param == "" then
local qry = db.getResult("SELECT `player_id`, `date`, `level`, `killer_name` FROM `death_list` ORDER BY `date` DESC LIMIT 0, " .. limit)
if(qry:getID() ~= -1) then
repeat
str = str .."\n "..os.date("%d %B %Y %X ", qry:getDataInt("date")).." "..getPlayerNameByGUID(qry:getDataString("player_id")).." died at level "..qry:getDataInt("level").." by:\n"..qry:getDataString("killer_name")
until not(qry:next())
qry:free()
else
str = "N?o h? mortes no servidor."
end
doPlayerPopupFYI(cid, "Last Deaths:\n\n" .. str)
return true
end
local getGuid = getPlayerGUIDByName(param:lower())
if not getGuid then doPlayerSendCancel(cid, "Este Player n?o existe.") return true end
local qry = db.getResult("SELECT `id`, `date`, `level`, `killer_name` FROM `death_list` WHERE `player_id` = " .. getGuid .." ORDER BY `date` DESC LIMIT 0, " .. limit)
if(qry:getID() ~= -1) then
repeat
str = str .."\n "..os.date("%d %B %Y %X ", qry:getDataInt("date")).." died at level "..qry:getDataInt("level").." by:\n"..qry:getDataString("killer_name")
until not(qry:next())
qry:free()
else
str = "N?o h? mortes."
end
doPlayerPopupFYI(cid, "Last Deaths of: " .. param .. ".\n\n" .. str)
return true
end
 
Back
Top