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

[Parcially SOLVED] attemp to index a nil value error

snacky

New Member
Joined
Apr 16, 2009
Messages
126
Reaction score
1
Thank you, now I want to know how can I achieve the removal function takes the coords from the config lines? for Example:

Notice that I need the teleport to be removed by the location stated on each TP by its actionID

Code:
local config = {
    bosses={---aid of portal, position where it sends, value it sets, text it shows
        --killed tidehunter
        [7501] = {pos={x=31863, y=32894, z=1, stackpos=1}, value=1, text="", removepos={x=31978, y=32811, z=7, stackpos=1}},
        [7002] = {pos={x=1128, y=1150, z=12, stackpos=1}, value=2, text="Test"},
        [7003] = {pos={x=1046, y=1206, z=13, stackpos=1}, value=3, text="Test"},


Code:
local function removal(position)
    local t= config.bosses[ -what should be placed here?- ]
    doRemoveThing(getTileItemById(t.removepos, config.uniqueId).uid, 1)
    return TRUE
end

-- BELOW THIS LINE IS SOLVED --
Im triying to remove a teleport, once a player go throught it. The teleport is created once the monster dies.

Here is the code, me trying to doRemoveItem, but its giving me error:

Code:
local config = {
    bosses={---aid of portal, position where it sends, value it sets, text it shows
        --killed tidehunter
        [7501] = {pos={x=31863, y=32894, z=1, stackpos=1}, value=1, text=""},
        [7002] = {pos={x=1128, y=1150, z=12, stackpos=1}, value=2, text="Test"},
        [7003] = {pos={x=1046, y=1206, z=13, stackpos=1}, value=3, text="Test"},
        [7004] = {pos={x=1152, y=1196, z=13, stackpos=1}, value=4, text="Test"},
        [7005] = {pos={x=1245, y=1297, z=12, stackpos=1}, value=5, text="Test"},
        [7006] = {pos={x=1066, y=1309, z=13, stackpos=1}, value=6, text="Test"}
        },
    mainroom={---aid, position, lowest value that can use this portal, text
        [7101] = {pos={x=1173, y=1139, z=12, stackpos=1}, value=1, text="Test"},
        [7102] = {pos={x=1128, y=1150, z=12, stackpos=1}, value=2, text="Test"}
        },
    portals={---aid, position, text
        [7200] = {pos={x=1715, y=1427, z=14}, text="Escaping to the Retreat..."},
        [7201] = {pos={x=1717, y=1256, z=8}, text="Entering Ushuriel's Ward"}
        },
    storage=77090,---storage used in boss and mainroom portals
    uniqueId = 5024,
    walkback="You don't have enough energy to enter this portal",---message if you cannot use mainroom portal
    e={}    }----dunno whats this but have to be like this to make doCreatureSayWithDelay working, DON'T TOUCH}

--teleport position to be removed
local position = { x=31978, y=32811, z=7}

local function removal(position)
    doRemoveThing(getTileItemById(position, config.uniqueId).uid, 1)
    return TRUE
end

    function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) == TRUE then
        if(config.bosses[item.actionid]) then
            local t= config.bosses[item.actionid]
            if getPlayerStorageValue(cid, config.storage)< t.value then
                setPlayerStorageValue(cid, config.storage, t.value)
            end
            doTeleportThing(cid, t.pos)
            doSendMagicEffect(t.pos, CONST_ME_TELEPORT)
            --doCreatureSayWithDelay(cid,t.text,19,1, config.e)
            addEvent(removal, position)
        elseif(config.mainroom[item.actionid]) then
            local t= config.mainroom[item.actionid]
            if getPlayerStorageValue(cid, config.storage)>=t.value then
                doTeleportThing(cid, t.pos)
                doCreatureSayWithDelay(cid,t.text,19,1,config.e)
            else
                doTeleportThing(cid, fromPosition)
                doCreatureSay(cid, config.walkback, 19)
            end
        elseif(config.portals[item.actionid]) then
            local t= config.portals[item.actionid]
            doTeleportThing(cid, t.pos)
            doCreatureSayWithDelay(cid,t.text,19,1,config.e)
        end
    end
end

ERRROR:
[Error - MoveEvents Interface]
In a timer event called from:
data/...........
Description:
attemp to index a nil value
stack traceback;
[C:] in function 'getTileItemById'

What could be the problem? All i need, is the teleport is removed once the character has went throught it.

Any help would be Appreciated!
 
Last edited:
Try changing addEvent(removal, position) to addEvent(removal, 0, position)

If that doesn't work then until someone who knows a better way to incorporate position into your event can help, just put the "local position =" line in your local function removal.
 
Thank you, it worked!

local position = line in the local function removal.

Code:
local function removal(position)
local position = { x=31978, y=32811, z=7}
    doRemoveThing(getTileItemById(position, config.uniqueId).uid, 1)
    return TRUE
end

That's it the fix
 
Thank you, now I want to know how can I achieve the removal function takes the coords from the config lines? for Example:
notice the i want the teleport be removed by the location stated on each teleport by its actionID

Code:
local config = {
    bosses={---aid of portal, position where it sends, value it sets, text it shows
        --killed tidehunter
        [7501] = {pos={x=31863, y=32894, z=1, stackpos=1}, value=1, text="", removepos={x=31978, y=32811, z=7, stackpos=1}},
        [7002] = {pos={x=1128, y=1150, z=12, stackpos=1}, value=2, text="Test"},
        [7003] = {pos={x=1046, y=1206, z=13, stackpos=1}, value=3, text="Test"},


Code:
local function removal(position)
    local t= config.bosses[ -what should be placed here?- ]
    doRemoveThing(getTileItemById(t.removepos, config.uniqueId).uid, 1)
    return TRUE
end
 
Last edited:
try this
Code:
local config = {
    bosses={---aid of portal, position where it sends, value it sets, text it shows
        --killed tidehunter
        [7501] = {pos={x=31863, y=32894, z=1, stackpos=1}, value=1, text="", removepos={x=31978, y=32811, z=7, stackpos=1}},
        [7002] = {pos={x=1128, y=1150, z=12, stackpos=1}, value=2, text="Test", removepos={x=31978, y=32811, z=7, stackpos=1}},
        [7003] = {pos={x=1046, y=1206, z=13, stackpos=1}, value=3, text="Test", removepos={x=31978, y=32811, z=7, stackpos=1}},
        [7004] = {pos={x=1152, y=1196, z=13, stackpos=1}, value=4, text="Test", removepos={x=31978, y=32811, z=7, stackpos=1}},
        [7005] = {pos={x=1245, y=1297, z=12, stackpos=1}, value=5, text="Test", removepos={x=31978, y=32811, z=7, stackpos=1}},
        [7006] = {pos={x=1066, y=1309, z=13, stackpos=1}, value=6, text="Test", removepos={x=31978, y=32811, z=7, stackpos=1}}
        },
    mainroom={---aid, position, lowest value that can use this portal, text
        [7101] = {pos={x=1173, y=1139, z=12, stackpos=1}, value=1, text="Test"},
        [7102] = {pos={x=1128, y=1150, z=12, stackpos=1}, value=2, text="Test"}
        },
    portals={---aid, position, text
        [7200] = {pos={x=1715, y=1427, z=14}, text="Escaping to the Retreat..."},
        [7201] = {pos={x=1717, y=1256, z=8}, text="Entering Ushuriel's Ward"}
        },
    storage=77090,---storage used in boss and mainroom portals
    uniqueId = 5024,
    walkback="You don't have enough energy to enter this portal",---message if you cannot use mainroom portal
    e={}    }----dunno whats this but have to be like this to make doCreatureSayWithDelay working, DON'T TOUCH}

local function removal(par)
    doRemoveThing(getTileItemById(par.removepos, config.uniqueId).uid, 1)
    return TRUE
end

function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) == TRUE then
        if(config.bosses[item.actionid]) then
            local t= config.bosses[item.actionid]
            if getPlayerStorageValue(cid, config.storage)< t.value then
                setPlayerStorageValue(cid, config.storage, t.value)
            end
            doTeleportThing(cid, t.pos)
            doSendMagicEffect(t.pos, CONST_ME_TELEPORT)
            --doCreatureSayWithDelay(cid,t.text,19,1, config.e)
            local par = {removepos = config.bosses[item.actionid].removepos}
            addEvent(removal, 0, par)
        elseif(config.mainroom[item.actionid]) then
            local t= config.mainroom[item.actionid]
            if getPlayerStorageValue(cid, config.storage)>=t.value then
                doTeleportThing(cid, t.pos)
                doCreatureSayWithDelay(cid,t.text,19,1,config.e)
            else
                doTeleportThing(cid, fromPosition)
                doCreatureSay(cid, config.walkback, 19)
            end
        elseif(config.portals[item.actionid]) then
            local t= config.portals[item.actionid]
            doTeleportThing(cid, t.pos)
            doCreatureSayWithDelay(cid,t.text,19,1,config.e)
        end
    end
end
 
Back
Top