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

TFS 1.0 Playerdeath.lua - attempt to index a nil value

Pnurt

New Member
Joined
Apr 22, 2009
Messages
205
Reaction score
0
I'm using TFS 1.0 and everytime a player dies this error comes up.
9cd208eb845189a3c97d8b4234f11f6b.png



Another thing is also that monsters wont attack.

It feels like I'm missing something essential. Though I am using a fresh TFS 1.0 latest everything with fresh database.
 
Like I said monsters won't attack either. It's like theres something fucked up with the whole thing, though I'm using the latest data files and latest build of TFS 1.0.

Is there a stable TFS 1.0 for 10.41?

Code:
local deathListEnabled = true
local maxDeathRecords = 5

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local player = Player(cid)

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.")
    if not deathListEnabled then
        return
    end

    local byPlayer = 0
    local killerCreature = Creature(killer)
    if killerCreature == nil then
        killerName = "field item"
    else
        if killerCreature:isPlayer() then
            byPlayer = 1
        else
            local master = killerCreature:getMaster()
            if master and master ~= killerCreature and master:isPlayer() then
                killerCreature = master
                byPlayer = 1
            end
        end
        killerName = killerCreature:getName()
    end

    local byPlayerMostDamage = 0
    if mostDamage == 0 then
        mostDamageName = "field item"
    else
        local mostDamageKiller = Creature(mostDamage)
        if mostDamageKiller:isPlayer() then
            byPlayerMostDamage = 1
        else
            local master = mostDamageKiller:getMaster()
            if master and master ~= mostDamageKiller and master:isPlayer() then
                mostDamageKiller = master
                byPlayerMostDamage = 1
            end
        end
        mostDamageName = mostDamageKiller:getName()
    end

    local playerGuid = player:getGuid()
    db.query("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (" .. playerGuid .. ", " .. os.time() .. ", " .. player:getLevel() .. ", " .. db.escapeString(killerName) .. ", " .. byPlayer .. ", " .. db.escapeString(mostDamageName) .. ", " .. byPlayerMostDamage .. ", " .. unjustified .. ", " .. mostDamage_unjustified .. ")")
    local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)

    local deathRecords = 0
    local tmpResultId = resultId
    while tmpResultId ~= false do
        tmpResultId = result.next(resultId)
        deathRecords = deathRecords + 1
    end

    if resultId ~= false then
        result.free(resultId)
    end

    while deathRecords > maxDeathRecords do
        db.query("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT 1")
        deathRecords = deathRecords - 1
    end

    if byPlayer == 1 then
        local guild = player:getGuild()
        local targetGuild = guild and guild:getId()
        if targetGuild ~= 0 then
            local killerGuild = killerCreature:getGuild():getId()
            if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(cid, killerCreature) then
                local warId = false
                resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
                if resultId ~= false then
                    warId = result.getDataInt(resultId, "id")
                    result.free(resultId)
                end

                if warId ~= false then
                    db.query("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(killerName) .. ", " .. db.escapeString(player:getName()) .. ", " .. killerGuild .. ", " .. targetGuild .. ", " .. os.time() .. ", " .. warId .. ")")
                end
            end
        end
    end
end
 
Line 70 Seems to be associated with a Guild.
Index might be your website.
Just pondering though, I don't know much. :(
 
Well first of all, It tries to get the guild of the "attacker" even if there is no attacker.

Meaning if you ever die by a Condition, or Field it will cause an error.
Plus since it is trying to get Guild, it probably fails if it is a creature also, since monsters cannot be in guilds.

Fix that and you fix this script.
As for monsters not attacking... If you have some other "guild members cannot attack each other" or something you might of made the same mistake, and made it so monsters cannot attack you (because of course, monsters cannot be in guilds)
 
Monsters were probably not attacking because of a commit from yesterday, update your source again now, and then recompile and see if it works. If the monsters were only attacking you one hit then following you, that was for sure the problem...
 
Back
Top