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

Lua Deathlist killer name

E

Evil Puncker

Guest
I found a really old script for death broadcast, but it is just showing "player name [lvl]" and not the rest of was killed by etc... message:

Lua:
function onDeath(cid, corpse)
    local creature = Creature(cid)
    local damageMap = creature:getDamageMap()
    for creatureId, damage in pairs(damageMap) do
        local thing = Creature(creatureId)
    end
    i = 0
    str = getCreatureName(cid).." ["..getPlayerLevel(cid).."]"
    for _, pid in ipairs(damageMap) do
        i = i + 1
        if (i == 1) then
            if(#damageMap <= 1) then
                str = str.." was killed by "
            elseif(#damageMap > 1 and #damageMap <= 4) then
                str = str.." was slain by "
            elseif(#damageMap > 4 and #damageMap <= 7) then
                str = str.." was crushed by "
            elseif(#damageMap > 7 and #damageMap <= 10) then
                str = str.." was eliminated by "
            elseif(#damageMap > 10) then
                str = str.." was annihilated by "
            end
        elseif (i == #damageMap) then
            str = str.." and "
        else
            str = str..", "
        end

        if not(isPlayer(pid) or isMonster(pid)) then
            str = str.."a field item"
        elseif isSummon(pid) then
            str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid))
        elseif isPlayer(pid) then
            str = str..""..getCreatureName(pid)
        elseif isMonster(pid) then
            str = str.."a "..getCreatureName(pid):lower()
        end
    end
    str = str.."."
    Game.broadcastMessage(str, MESSAGE_STATUS_WARNING)
    print(str)
    return true
end

what could be wrong? I'm using tfs 1.3
 
Try this:


Lua:
function onDeath(cid, corpse)
    local creature = Creature(cid)
    local damageMap = creature:getDamageMap()
   
    local str = getCreatureName(cid).." ["..getPlayerLevel(cid).."]"
   
    if(#damageMap <= 1) then
        str = str.." was killed by "
    elseif(#damageMap > 1 and #damageMap <= 4) then
        str = str.." was slain by "
    elseif(#damageMap > 4 and #damageMap <= 7) then
        str = str.." was crushed by "
    elseif(#damageMap > 7 and #damageMap <= 10) then
        str = str.." was eliminated by "
    elseif(#damageMap > 10) then
        str = str.." was annihilated by "
    end
   
    local i = 0      
    for pid, _ in ipairs(damageMap) do
        i = i + 1
       
        
        if (i == #damageMap) then
            str = str.." and "
        elseif (i ~= 1) then
            str = str..", "
        end

        if not(isPlayer(pid) or isMonster(pid)) then
            str = str.."a field item"
        elseif isSummon(pid) then
            str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid))
        elseif isPlayer(pid) then
            str = str..""..getCreatureName(pid)
        elseif isMonster(pid) then
            str = str.."a "..getCreatureName(pid):lower()
        end
    end
   
    str = str.."."
    Game.broadcastMessage(str, MESSAGE_STATUS_WARNING)
    print(str)
    return true
end
 
Back
Top