otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

Improvement suggestion in the playerdeath table #4429

Open luanluciano93 opened 1 year ago

luanluciano93 commented 1 year ago

Before creating an issue, please ensure:

Expected behaviour

Columns "killed_by" and "mostdamage_by" cannot carry the player ID? I had problems when I used a "change name", the table stored the old names.

https://github.com/otland/forgottenserver/blob/master/schema.sql#L271-L284

mano368 commented 1 year ago

I know its better to have as default, but here is the necessary modification.

local function getKiller(killer)
    if not killer then
        return false, "field item"
    end

    if killer:isPlayer() then
        return true, killer:getGuid()
    end

    local master = killer:getMaster()
    if master and master ~= killer and master:isPlayer() then
        return true, master:getGuid()
    end

    return false, killer:getName()
end

now you need to change your acc to get player by id too