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

ERROR TFS 1.3

alisonrenna

New Member
Joined
Sep 24, 2011
Messages
29
Reaction score
2
...ipts/scripts/quests/cults of tibia/vortexSpawnCarlin.lua:20: attempt to index local 'portal1' (a nil value)
stack traceback:
[C]: in function '__index'
.ipts/scripts/quests/cults of tibia/vortexSpawnCarlin.lua:20: in function <...ipts/scripts/quests/cults of tibia/vortexSpawnCarlin.lua:18>

...ipts/scripts/quests/cults of tibia/vortexSpawnCarlin.lua:23: attempt to index local 'portal2' (a nil value)
stack traceback:
[C]: in function '__index'
.ipts/scripts/quests/cults of tibia/vortexSpawnCarlin.lua:23: in function <...ipts/scripts/quests/cults of tibia/vortexSpawnCarlin.lua:24>


ERROR NO TFS

SCRIPT

function onKill(creature, target, item)
if not creature or not creature:isPlayer() then
return true
end
if not target or not target:isMonster() then
return true
end

local cName = target:getName():lower()

if(isInArray({'cult enforcer', 'cult believer', 'cult scholar'}, cName)) then
local posCorpo = target:getPosition()
local rand = math.random(1,2)
if rand == 1 then
Game.createItem(26140, 1, posCorpo):setActionId(5580)
addEvent(function()
local portal1 = Tile(posCorpo):getItemById(26140)
portal1:remove(1) end, (1*60*1000), 26140, 1, posCorpo)
end
if rand == 2 then
Game.createItem(26138, 1, posCorpo):setActionId(5580)
addEvent(function()
local portal2 = Tile(posCorpo):getItemById(26138)
portal2:remove(1) end, (1*60*1000), 26138, 1, posCorpo)
end
end
return true
end
 

Attachments

Lua:
function onKill(creature, target, item)
if not creature or not creature:isPlayer() then
return true
end
if not target or not target:isMonster() then
return true
end

local cName = target:getName():lower()

if(isInArray({'cult enforcer', 'cult believer', 'cult scholar'}, cName)) then
local posCorpo = target:getPosition()
local rand = math.random(1,2)
if rand == 1 then
Game.createItem(26140, 1, posCorpo):setActionId(5580)
addEvent(function()
local portal1 = Tile(posCorpo):getItemById(26140)
portal1:remove(1) end, (1*60*1000), 26140, 1, posCorpo)
end
if rand == 2 then
Game.createItem(26138, 1, posCorpo):setActionId(5580)
addEvent(function()
local portal2 = Tile(posCorpo):getItemById(26138)
portal2:remove(1) end, (1*60*1000), 26138, 1, posCorpo)
end
end
return true
end
 
In those event of yours you are doing the same stuff so it is better to move it to separate function like
Lua:
function functionName(pos, itemId)
    local portal = Tile(pos):getItemById(itemId)
    portal:remove(1)
end
and then
addEvent(functionName, execution_time, pos, itemId)
In general first arg to the addEvent() is function name, second is execution time and every thing after that are args passed to the function pointed in first arg
 
In fact, he is tending to remove an item that is no longer on the floor, the player goes over and the item disappears, gaining storage, and then the function tries to remove the item that is no longer there, how can I solve this?
 
Lua:
local function removeVortex(pos, itemId)
    local portal = Tile(pos):getItemById(itemId)
    portal:remove(1)
end

function onKill(creature, target, item)
    if not creature or not creature:isPlayer() then
    return true
end

    if not target or not target:isMonster() then
    return true
end

local cName = target:getName():lower()
    if(isInArray({'cult enforcer', 'cult believer', 'cult scholar'}, cName)) then
    local posCorpo = target:getPosition()
    local rand = math.random(1,2)

    if rand == 1 then
    Game.createItem(26140, 1, posCorpo):setActionId(5580)
    addEvent(removeVortex, 60000, posCorpo, 26140)
    end

    if rand == 2 then
    Game.createItem(26138, 1, posCorpo):setActionId(5580)
    addEvent(removeVortex, 60000, posCorpo, 26138)
    end
end

return true
end
 
Back
Top