• 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 onDeath value Issue TFS 0.3.6

GP

New Member
Joined
Oct 11, 2018
Messages
2
Reaction score
1
Hello,

im new here :)

im using theForgottenServer0.3.6 and i have a Problem with the onDeath function:

I've created some checks for the Paramete Values:


Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local cid = creature
 
    print("------PARAMETER CHECK------.")
 
    -- Print killer isPlayer ?
    if isPlayer(killer[1]) then
        print("Killer is a player.")
    end
 
    -- Print CID id Player or Creature?
    if isPlayer(cid) then
        print("cid is Player")
    elseif not isPlayer(cid) and isCreature(cid) then
        print("cid ist Creature")
    end
 
    -- Print mostDamageKiller is Player?
    if isPlayer(mostDamageKiller) then
        print("MostDamageKiller ist Player")  
    end
 
    -- Print CID
    if cid ~= nil then
      print("creature Value: "..cid..".")
    end

    -- Print CreatureCorpse
    if corpse ~= nil then
        print("CorpseContent: "..corpse.itemid..".")
    end
 
    -- Print MostDamageKiller Value
    if(mostDamageKiller ~= nil) then
        print("MostDamageKiller Value:"..mostDamageKiller..".")
    end
 
    -- Print CreatureName
    local creaturename = getCreatureName(cid)
    if creaturename ~= nil then
        print("CreatureName: "..creaturename..".")
    end
 
    -- Print Position of Creature
    local position = getCreaturePosition(cid)
    if position ~= nil then
        print("Position: "..position..".")
    end
 
    print("------PARAMETER CHECK END------.")

But in the Result are Some Issues:


1. MostDamageKiller = nil

2. Position is a Table
Position ServerLog:
Code:
[27/10/2018 15:39:17] Description:
[27/10/2018 15:39:17] data/creaturescripts/scripts/inquisitionPortals.lua:105: attempt to concatenate local 'position' (a table value)
[27/10/2018 15:39:17] stack traceback:
[27/10/2018 15:39:17]     data/creaturescripts/scripts/inquisitionPortals.lua:105: in function <data/creaturescripts/scripts/inquisitionPortals.lua:57>


FullServerLog:
Code:
[27/10/2018 15:39:17] ------PARAMETER CHECK------.
[27/10/2018 15:39:17] Killer is a player.
[27/10/2018 15:39:17] cid is Creature
[27/10/2018 15:39:17] creature Value: 1073764678.
[27/10/2018 15:39:17] CorpseContent: 6336.
[27/10/2018 15:39:17] CreatureName: Juggernaut.

[27/10/2018 15:39:17] [Error - CreatureScript Interface]
[27/10/2018 15:39:17] data/creaturescripts/scripts/inquisitionPortals.lua:onDeath
[27/10/2018 15:39:17] Description:
[27/10/2018 15:39:17] data/creaturescripts/scripts/inquisitionPortals.lua:105: attempt to concatenate local 'position' (a table value)
[27/10/2018 15:39:17] stack traceback:
[27/10/2018 15:39:17]     data/creaturescripts/scripts/inquisitionPortals.lua:105: in function <data/creaturescripts/scripts/inquisitionPortals.lua:57>


If I try to fix the Position by adding an Index:
Code:
-- Print Position of Creature
   local position = getCreaturePosition(cid)
   if position ~= nil then
       print("Position: "..position[1]..".")
   end

I'm getting this Result:
Code:
[27/10/2018 15:53:54] ------PARAMETER CHECK------.
[27/10/2018 15:53:54] Killer is a player.
[27/10/2018 15:53:54] cid ist Creature
[27/10/2018 15:53:54] Creature Value: 1073764674.
[27/10/2018 15:53:54] CorpseContent: 6336.
[27/10/2018 15:53:54] CreatureName: Juggernaut.

[27/10/2018 15:53:54] [Error - CreatureScript Interface]
[27/10/2018 15:53:54] data/creaturescripts/scripts/inquisitionPortals.lua:onDeath
[27/10/2018 15:53:54] Description:
[27/10/2018 15:53:54] data/creaturescripts/scripts/inquisitionPortals.lua:109: attempt to concatenate field '?' (a nil value)
[27/10/2018 15:53:54] stack traceback:
[27/10/2018 15:53:54]     data/creaturescripts/scripts/inquisitionPortals.lua:109: in function <data/creaturescripts/scripts/inquisitionPortals.lua:57>

Why i cant access Position?
Why is MostDamageKiller nil?`


Would be great if anyone can help me with this or
discribe whats exactly in Tables mostDamageKiller, position and in parameter corpse



Thanks :)
 
Last edited:
you have the parameters wrong because you're using 0.3.6
the correct parameters for onDeath is onDeath(cid, corpse, deathList) peonso/forgottenserver036pl1
also, position is a table containing x y z
so you use position.x, position.y, position.z to access the values because you can't concatenate a table to a string, you have to index them all manually
 
Ahhh Thanks!

Do you know if there is a Stabil Version for Tibia 8.60 where
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
are implemented?


i guess
Tile(position):getTopDownItem()
also wont work in this Version, right?
 
i guess
Tile(position):getTopDownItem()
also wont work in this Version, right?

Code:
function getTileTopDownItem(p)
    local creatures = getTileInfo(p).creatures
    local items = getTileInfo(p).items
    if items >= 1 then
        local t = getThingFromPos({ x = p.x, y = p.y, z = p.z, stackpos = creatures+items })
        if t.uid ~= 0 then
            return t
        end
    end
    return false
end
 
Back
Top