• 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 Annihilator script(?) Simple problem(?)

JackP3

New Member
Joined
Aug 6, 2014
Messages
12
Reaction score
0
My annihilator script refuses to teleport the players, nothing happens when i use the lever, except the lever switching side.. what have I done wrong?

Ingame
Code:
Changed uniqueID to lever:
ItemID: [1945], UniqueID: [8007].
Position: [X: 1126] [Y: 820] [Z: 6].

Actions.xml
Code:
     <action uniqueid="8007" event="script" value="quests/fire instance.lua"/>

\scripts\quests\fire instance.lua

Code:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 400,
    storage = 30015
}

local playerPosition =
{
    {x = 1125, y = 820, z = 6},
    {x = 1125, y = 821, z = 6}
    }

local newPosition =
{
    {x = 557, y = 1012, z = 4},
    {x = 557, y = 1013, z = 4}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only run this instance once a day!")
        else
            doTransformItem(item.uid, item.itemid - 1)
        end

        return true
    end

    if(item.itemid ~= 1945) then
        return true
    end

    local players = {}
    for _, pos in ipairs(playerPosition) do
        local pid = getTopCreature(pos).uid
        if(pid == 0 or not isPlayer(pid) or getPlayerStorageValue(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end

        players[i] = pid
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(playerPosition[i], CONST_ME_POFF)
        doTeleportThing(pid, newPosition[i], false)
        doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
 
Change
Code:
event="script" value="quests/fire instance.lua"
To
Code:
script="quests/fire instance.lua"
Aint working :s Anyhow now I can't use the lever if I'm not standing on the 2 spots, but I'm not getting teleported to the destination

Thanks for you answer tho :))!
 
Go to action/actions.xml and paste this:
Code:
<action uniqueid="5000" script="annihLever.lua"/>

Now go to actions/scripts/ and create new lua and name it: annihLever.lua and paste the code from here:
https://raw.githubusercontent.com/PrinterLUA/FORGOTTENSERVER-ORTS/master/data/actions/scripts/annihilator quest/annihilatorQuestLever.lua

Now go into your mapeditor and edit the annih lever and put UID: 5000
I did it exactly like that, still not working :/ I deleted all demon spawns except 1 and changed the position for it to a random place in the room (so it wouldnt mess with script that i removed) This is what i changed i the script to get it optimized for my serv
Code:
    daily = false,
    centerDemonRoomPosition = Position(557, 1013, 4),
    playerPositions = {
        Position(1125, 820, 6),
        Position(1125, 821, 6)
    },
    newPositions = {
        Position(557, 1012, 4),
        Position(557, 1013, 4)
    },
    demonPositions = {
        Position(557, 1013, 4)
    }
}
 
Try it:
Code:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 400,
    storage = 30015
}

local playerPosition =
{
    {x = 1125, y = 820, z = 6},
    {x = 1125, y = 821, z = 6}
    }

local newPosition =
{
    {x = 557, y = 1012, z = 4},
    {x = 557, y = 1013, z = 4}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only run this instance once a day!")
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
        return true
    elseif (item.itemid ~= 1945) then
        return true
    end

    local players = {}
    for _, pos in ipairs(playerPosition) do
        local pid = getTopCreature(pos).uid
        if(pid == 0 or not isPlayer(pid) or getPlayerStorageValue(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end

        players[i] = pid
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(playerPosition[i], CONST_ME_POFF)
        doTeleportThing(pid, newPosition[i], false)
        doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
 
Try it:
Code:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 400,
    storage = 30015
}

local playerPosition =
{
    {x = 1125, y = 820, z = 6},
    {x = 1125, y = 821, z = 6}
    }

local newPosition =
{
    {x = 557, y = 1012, z = 4},
    {x = 557, y = 1013, z = 4}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only run this instance once a day!")
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
        return true
    elseif (item.itemid ~= 1945) then
        return true
    end

    local players = {}
    for _, pos in ipairs(playerPosition) do
        local pid = getTopCreature(pos).uid
        if(pid == 0 or not isPlayer(pid) or getPlayerStorageValue(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end

        players[i] = pid
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(playerPosition[i], CONST_ME_POFF)
        doTeleportThing(pid, newPosition[i], false)
        doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
Doesnt work ;c But now I have errors: quests/fire instance.lua:40 table index is nil

Lever is just flopping around, but sometimes it doesnt work to use and then if you go back and forth on the tiles it starts to just work as a normal lever
 
The positions are correct?
local playerPosition = {
{x = 1125, y = 820, z = 6},
{x = 1125, y = 821, z = 6}
}



Try again:
Code:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 400,
    storage = 30015
}

local playerPosition = {
    {x = 1125, y = 820, z = 6},
    {x = 1125, y = 821, z = 6}
}

local newPosition =
{
    {x = 557, y = 1012, z = 4},
    {x = 557, y = 1013, z = 4}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only run this instance once a day!")
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
        return true
    elseif (item.itemid ~= 1945) then
        return true
    end

    local players = {}
    for _, pos in ipairs(playerPosition) do
        local pid = getTopCreature(pos).uid
        if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end
        players[i] = pid
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(playerPosition[i], CONST_ME_POFF)
        doTeleportThing(pid, newPosition[i], false)
        doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
 
The positions are correct?
local playerPosition = {
{x = 1125, y = 820, z = 6},
{x = 1125, y = 821, z = 6}
}



Try again:
Code:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 400,
    storage = 30015
}

local playerPosition = {
    {x = 1125, y = 820, z = 6},
    {x = 1125, y = 821, z = 6}
}

local newPosition =
{
    {x = 557, y = 1012, z = 4},
    {x = 557, y = 1013, z = 4}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only run this instance once a day!")
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
        return true
    elseif (item.itemid ~= 1945) then
        return true
    end

    local players = {}
    for _, pos in ipairs(playerPosition) do
        local pid = getTopCreature(pos).uid
        if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end
        players[i] = pid
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(playerPosition[i], CONST_ME_POFF)
        doTeleportThing(pid, newPosition[i], false)
        doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
Still isn't working, same errors
Code:
[15:54:28.126] [Error - Action Interface]
[15:54:28.127] data/actions/scripts/quests/fire instance.lua:onUse
[15:54:28.127] Description:
[15:54:28.127] data/actions/scripts/quests/fire instance.lua:38: table index is nil
[15:54:28.127] stack traceback:
[15:54:28.127]  data/actions/scripts/quests/fire instance.lua:38: in function <data/actions/scripts/quests/fire instance.lua:19>
When i stand on the first tile I can use it and it just changes sides without anything happening, and when i stand on the southern one it just tells me that it "isnt possible" Thanks for your reply tho <32
 
I did it exactly like that, still not working :/ I deleted all demon spawns except 1 and changed the position for it to a random place in the room (so it wouldnt mess with script that i removed) This is what i changed i the script to get it optimized for my serv
Code:
    daily = false,
    centerDemonRoomPosition = Position(557, 1013, 4),
    playerPositions = {
        Position(1125, 820, 6),
        Position(1125, 821, 6)
    },
    newPositions = {
        Position(557, 1012, 4),
        Position(557, 1013, 4)
    },
    demonPositions = {
        Position(557, 1013, 4)
    }
}
Instead of "not working" explain what it does, "not working" is to vague to know what's wrong.
So do you get errors, what exactly happens when you pull the lever, do you get textmessages/cancelmessages? Do you pull to lever or does it stays the same?
 
Instead of "not working" explain what it does, "not working" is to vague to know what's wrong.
So do you get errors, what exactly happens when you pull the lever, do you get textmessages/cancelmessages? Do you pull to lever or does it stays the same?
"When i stand on the first tile I can use it and it just changes sides without anything happening, and when i stand on the southern one it just tells me that it "isnt possible (that white "sorry not possible (in southern part of screen)"" Only error I get is the one i pasted in my last post!

With (changes sides) I mean that the lever is working like a lever without a script would
 
Work now:
Code:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 400,
    storage = 30015
}

local playerPosition = {
    {x = 1125, y = 820, z = 6},
    {x = 1125, y = 821, z = 6}
}

local newPosition =
{
    {x = 557, y = 1012, z = 4},
    {x = 557, y = 1013, z = 4}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only run this instance once a day!")
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
        return true
    elseif (item.itemid ~= 1945) then
        return true
    end

    local players = {}
    local i = 1
    for _, pos in ipairs(playerPosition) do
        local pid = getTopCreature(pos).uid
        if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end
        players[i] = pid
        i = i + 1
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(playerPosition[i], CONST_ME_POFF)
        doTeleportThing(pid, newPosition[i], false)
        doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
 
Back
Top