• 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
 
Try to replace this line:
Code:
doPlayerPopupFYI(cid, "Deathlist for player: " .. targetName .. ".\n\n" .. str)
with this:
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Deathlist for player: " .. targetName .. ".\n\n" .. str)
 
Try to replace this line:
Code:
doPlayerPopupFYI(cid, "Deathlist for player: " .. targetName .. ".\n\n" .. str)
with this:
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Deathlist for player: " .. targetName .. ".\n\n" .. str)

Perfect bro!

I get that:
17:09 Deathlist for player: Linterna.

07 November 2014 23:06:22 Killed at level 73 by:
Lukzerah Prokid, Cmywl Xoat, rotworm.
07 November 2014 21:28:28 Killed at level 73 by:
Todinhoo, News Na Missao, Cutter Slade.
07 November 2014 19:18:23 Killed at level 68 by:
Da Litsi.
07 November 2014 19:17:52 Killed at level 69 by:
Da Litsi.
07 November 2014 18:15:05 Killed at level 69 by:
El Satanaz, Sem Money, Flampz, Nto aprendiz,
Mahzui.
07 November 2014 02:27:29 Killed at level 65 by:
Stefan bodzin, Amad

But he dont show me ALL deaths! How i Do it?!

Another
17:11 Deathlist for player: News Na Missao.
08 November 2014 13:13:57 Killed at level 55 by:
Kissz Elite, fire elemental summoned by Soul'rush.
08 November 2014 13:03:37 Killed at level 55 by:
Bielzin Oz, Rasta Of Jaah, Swagzin, Imperial,
Beth Spagueth, Cmywl Xoat.
07 November 2014 21:54:53 Killed at level 55 by:
Sem Money, Quentim tarantino, Mahzui.
07 November 2014 21:24:26 Died at level 55 by:
war golem, fire annihilator.
07 November 2014 20:56:31 Killed at level 55 by:
Pvp Netinho Rulesz, Quenti

Notice that he did not finish writing the whole name of the player in the last line correctly. "Quinti" n the correct name is Quentim tarantino
 
Go into your config.lua and adjust this value:

Code:
maxDeathRecords = 5

Replace 5 with however many deaths you wish to show.
 
I dont need restart because my server are configured with 15 before. I dont know why he show just five.

My config was 5 before, I changed it to 10, did a restart and it works fine. Shows 10 instead of 5.
Try a restart and see what happens.

Also make sure the character you're looking at has more than 5 deaths :p
 
My config was 5 before, I changed it to 10, did a restart and it works fine. Shows 10 instead of 5.
Try a restart and see what happens.

Also make sure the character you're looking at has more than 5 deaths :p

Okay bro, i will restart and post the result there. So, look, i have explained better in other topic.

See the example:
7:11 Deathlist for player: News Na Missao.
08 November 2014 13:13:57 Killed at level 55 by:
Kissz Elite, fire elemental summoned by Soul'rush.
08 November 2014 13:03:37 Killed at level 55 by:
Bielzin Oz, Rasta Of Jaah, Swagzin, Imperial,
Beth Spagueth, Cmywl Xoat.
07 November 2014 21:54:53 Killed at level 55 by:
Sem Money, Quentim tarantino, Mahzui.
07 November 2014 21:24:26 Died at level 55 by:
war golem, fire annihilator.
07 November 2014 20:56:31 Killed at level 55 by:
Pvp Netinho Rulesz, Quenti
Notice that he did not finish writing the whole name of the player in the last line correctly. "Quinti" n the correct name is Quentim tarantino
 
It seems as though there is a limit of the amount of text that can be sent with doPlayerSendTextMessage into the player's console.

With doPlayerPopupFYI however I'm able to get the full 9 deaths, but in the console it stops at 7.5.
So that means there is probably a source/client limitation for how much text the player can receive in his chat at one given time.

That fixing is beyond me and will need the help of a more knowledgeable person.

@Limos might be able to help.

aILOdeE.png
 
Last edited:
It seems as though there is a limit of the amount of text that can be sent with doPlayerSendTextMessage into the player's console.

With doPlayerPopupFYI however I'm able to get the full 9 deaths, but in the console it stops at 7.5.
So that means there is probably a source/client limitation for how much text the player can receive in his chat at one given time.

That fixing is beyond me and will need the help of a more knowledgeable person.

@Limos might be able to help.

aILOdeE.png

Many thanks for try to help me brother @imkingran! You have arrived at the exact point. Understand all.
I need remove or change that limitation! Someone can help me to do it?
 
There is a limitation, yes. It's a client one as far as I am aware (try to spam on tibia, there is a character limit).
Maybe try to do a counter and when it reaches the limit (7?) it does it in another message.

No idea how to do that, but it shouldn't be that hard. Ask Limos :P
 
You can use
Code:
doShowTextDialog(cid, itemid, text)
Then you don't have the problem that it reaches the limit of amount of text.
 
Limos said that you can change:
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Deathlist for player: " .. targetName .. ".\n\n" .. str)
to:
Code:
doShowTextDialog(cid, 2317, "Deathlist for player: " .. targetName .. ".\n\n" .. str)
 
Last edited:
Limos said that you can change:
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Deathlist for player: " .. targetName .. ".\n\n" .. str)
to:
Code:
doShowTextDialog(cid, 2317, "Deathlist for player: " .. targetName .. ".\n\n" .. str)

Perfect! Fixed! Many thanks brothers @Limos @imkingran

One doubt! Have a limitation of deathlist number to put in config.lua?
 
What do you mean? You can just change the amount of maxDeathRecords in config.lua to any number for the max amount of deaths you want to show in the list.
 
What do you mean? You can just change the amount of maxDeathRecords in config.lua to any number for the max amount of deaths you want to show in the list.

I know bro. But my question was whether there was any limitation, alright? Assuming that I put the number 100 and then can crash.. Just simple doubt brah.

Thanks.

Topic solved.
 
How many deaths does this character have? Already tried to set the maxDeathRecords lower and see if the client is still crashing?
 
Back
Top