• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua TFS 0.3.6 Annihilator Quest

pepito999

New Member
Joined
Jul 19, 2011
Messages
33
Solutions
1
Reaction score
0
Hello, could someone explain to me how this scripts works, I am new to this. I downloaded a data pack that had this anihilator quest script but don't know how to make it work.

What do I need to put on lever action and unique ID?

Does storage has to be the same as unique id from lever and unique id from actions.xml?

I would really appreciate if someone could help me.

Thanks.

data/actions/actions.xml

XML:
<action uniqueid="30015" event="script" value="quests/annihilator.lua"/>

actions/scripts/quests/annihilator.lua

Lua:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 100,
    storage = 30015,
    entry =
    {
        {x = 782, y = 1461, z = 7},
        {x = 781, y = 1461, z = 7},
        {x = 780, y = 1461, z = 7},
        {x = 779, y = 1461, z = 7}
    },
    destination =
    {
        {x = 782, y = 1461, z = 8},
        {x = 781, y = 1461, z = 8},
        {x = 780, y = 1461, z = 8},
        {x = 779, y = 1461, z = 8}
    }
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end

        return true
    end

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

    local players = {}
    for _, position in ipairs(config.entry) do
        local pid = getTopCreature(position).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

        table.insert(players, pid)
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(config.entry[i], CONST_ME_POFF)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
 
Solution
Do you have multiple items on your map with the same UniqueId?
If there are multiple, only the first one loaded in the map will work.

Otherwise, check your console more closely, and see if there is an error related to this script upon start-up.
Thank you, finally it worked. But since it doesnt spawn demons I need to use the other one I found but need to eliminate the spawn of walls and stones. I eliminated some of the code, but I am new to this and cant make it work.
Post automatically merged:

Got it working with this new script I found from the user Frankit0. Thank you.



Lua:
-- Annihilator by Shawak v2.1

        -- CONFIG --

        local room = {     -- room with demons
        fromX = 33219,
        fromY = 31657,
        fromZ =...

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,487
Place lever 1945 on map.
Put UniqueId on lever. 30015.
Setup tile positions in script.
Setup spawn of 6 demons, as script does not spawn them.

storage can be a different value, but no reason not to use the same.
 
OP
OP
P

pepito999

New Member
Joined
Jul 19, 2011
Messages
33
Solutions
1
Reaction score
0
I placed lever 1945 on map, put the unique id 30015 on lever and setpup tile positions in script but when I tried using the lever, it doesnt do anything. Any advice?
Post automatically merged:

Found another anihilator quest script that has setup spawn but I need to eliminate spawn of stones and walls, could anyone help me fix this?

Lua:
local config = {
    daily = "no", -- allow only one team to enter per day? (like in global)
    level = 100,
    storage = 30015,
    room = {
        {x = 33218, y = 31656, z = 13},
        {x = 33225, y = 31662, z = 13}
    },
    stand = {
        {x = 33225, y = 31671, z = 13},
        {x = 33224, y = 31671, z = 13},
        {x = 33223, y = 31671, z = 13},
        {x = 33222, y = 31671, z = 13}
    },
    destination = {
        {x = 33222, y = 31659, z = 13},
        {x = 33221, y = 31659, z = 13},
        {x = 33220, y = 31671, z = 13},
        {x = 33219, y = 31671, z = 13}
    },
    wall = {
        {x = 33225, y = 31659, z = 13}
    },
    rocks = {
        {x = 33219, y = 31657, z = 13},
        {x = 33221, y = 31657, z = 13},
        {x = 33219, y = 31659, z = 13},
        {x = 33220, y = 31659, z = 13},
        {x = 33221, y = 31659, z = 13},
        {x = 33222, y = 31659, z = 13},
        {x = 33223, y = 31659, z = 13},
        {x = 33224, y = 31659, z = 13},
        {x = 33220, y = 31661, z = 13},
        {x = 33222, y = 31661, z = 13}
    },
    demons = {
        {x = 33219, y = 31657, z = 13},
        {x = 33221, y = 31657, z = 13},
        {x = 33223, y = 31659, z = 13},
        {x = 33224, y = 31659, z = 13},
        {x = 33220, y = 31661, z = 13},
        {x = 33222, y = 31661, z = 13}
    }
}
 
local function areaCheck(area)
    local monsters, players = {}, {}
    for x = config.room[1].x, config.room[2].x do
        for y = config.room[1].y, config.room[2].y do
            local t = getThingFromPos({x=x, y=y, z=config.room[1].z, stackpos=253})
            if t.uid > 0 then
                if isPlayer(t.uid) then
                    table.insert(players, t.uid)
                elseif isMonster(t.uid) then
                    table.insert(monsters, t.uid)
                end
            end
        end
    end
    return monsters, players
end
 
config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1945) then
        if(config.daily) then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        else
            local monsters, players = areaCheck(config.room)
            if #players > 0 then
                return doPlayerSendCancel(cid, "There are players inside, please be patient.")
            elseif #monsters > 0 then
                for _, k in pairs(monsters) do
                    doRemoveThing(k)
                end
            end
 
            for _, v in ipairs(config.rocks) do
                doCreateItem(1285, 1, v)
            end
 
            local closed, open = getTileItemById(config.wall[1], 5108), getTileItemById(config.wall[1], 5109)
            if(closed.uid > 0) then
                doTransformItem(closed.uid, 1025)
            elseif(open.uid > 0) then
                doTransformItem(open.uid, 1025)
            end
 
            doTransformItem(item.uid, item.itemid + 1)
        end
        return true
    end
 
    if(item.itemid ~= 1946) then
        return true
    end
 
    local players = {}
    for _, position in ipairs(config.stand) do
        local pid = getTopCreature(position).uid
        if(pid == 0 or not isPlayer(pid)) then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        elseif(getCreatureStorage(pid, config.storage) > 0) then
            return doPlayerSendCancel(cid, "Someone has already completed this quest.")
        elseif(getPlayerLevel(pid) < config.level) then
            return doPlayerSendCancel(cid, "Someone is below level 100.")
        end
 
        table.insert(players, pid)
    end
 
    local stones = {}
    for _, v in ipairs(config.rocks) do
        local st = getTileItemById(v, 1285)
        table.insert(stones, st)
    end
 
    for _, st in ipairs(stones) do
        doRemoveItem(st.uid, 1)
    end
 
    local wall = getTileItemById(config.wall[1], 1025)
    if(wall.uid > 0) then
        doTransformItem(wall.uid, 5108)
    end
 
    for _, pos in ipairs(config.demons) do
        doCreateMonster("Demon", pos, false, false) --TFS 0.3.6 -> [ doCreateMonster("Demon", pos) ]
        doSendMagicEffect(pos, CONST_ME_ENERGYAREA)
    end
 
    for i, pid in ipairs(players) do
        doSendMagicEffect(config.stand[i], CONST_ME_POFF)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_TELEPORT)
    end
 
    doTransformItem(item.uid, item.itemid - 1)
    return true
end
 
Last edited:

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,487
I placed lever 1945 on map, put the unique id 30015 on lever and setpup tile positions in script but when I tried using the lever, it doesnt do anything. Any advice?
Here's your script with some prints.

When you use the lever, check your console and find out what's going wrong.

Lua:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 100,
    storage = 30015,
    entry =
    {
        {x = 782, y = 1461, z = 7},
        {x = 781, y = 1461, z = 7},
        {x = 780, y = 1461, z = 7},
        {x = 779, y = 1461, z = 7}
    },
    destination =
    {
        {x = 782, y = 1461, z = 8},
        {x = 781, y = 1461, z = 8},
        {x = 780, y = 1461, z = 8},
        {x = 779, y = 1461, z = 8}
    }
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    print("itemid being used = " .. item.itemid)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
        return true
    end
    
    if(item.itemid ~= 1945) then
        return true
    end
    
    local players = {}
    for _, position in ipairs(config.entry) do
        local pid = getTopCreature(position).uid
        if pid == 0 or not isPlayer(pid) then
            print("No player on this position! (x = " .. position.x .. ", y = " .. position.y .. ", z = " .. position.z .. ")")
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        elseif getPlayerLevel(pid) < config.level then
            print("player is not level " .. config.level .. "+")
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        elseif getCreatureStorage(pid, config.storage) > 0 then
            print("player has completed quest before.")
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end
        
        print("Player (" .. getCreatureName(pid) .. ") added to table successfully.")
        table.insert(players, pid)
    end
    
    print("All players on tiles. Teleporting..")
    for i, pid in ipairs(players) do
        doSendMagicEffect(config.entry[i], CONST_ME_POFF)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
    end
    
    print("All players were teleported.")
    doTransformItem(item.uid, item.itemid + 1)
    return true
end
 
OP
OP
P

pepito999

New Member
Joined
Jul 19, 2011
Messages
33
Solutions
1
Reaction score
0
Here's your script with some prints.

When you use the lever, check your console and find out what's going wrong.

Lua:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 100,
    storage = 30015,
    entry =
    {
        {x = 782, y = 1461, z = 7},
        {x = 781, y = 1461, z = 7},
        {x = 780, y = 1461, z = 7},
        {x = 779, y = 1461, z = 7}
    },
    destination =
    {
        {x = 782, y = 1461, z = 8},
        {x = 781, y = 1461, z = 8},
        {x = 780, y = 1461, z = 8},
        {x = 779, y = 1461, z = 8}
    }
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    print("itemid being used = " .. item.itemid)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
        return true
    end
  
    if(item.itemid ~= 1945) then
        return true
    end
  
    local players = {}
    for _, position in ipairs(config.entry) do
        local pid = getTopCreature(position).uid
        if pid == 0 or not isPlayer(pid) then
            print("No player on this position! (x = " .. position.x .. ", y = " .. position.y .. ", z = " .. position.z .. ")")
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        elseif getPlayerLevel(pid) < config.level then
            print("player is not level " .. config.level .. "+")
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        elseif getCreatureStorage(pid, config.storage) > 0 then
            print("player has completed quest before.")
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end
      
        print("Player (" .. getCreatureName(pid) .. ") added to table successfully.")
        table.insert(players, pid)
    end
  
    print("All players on tiles. Teleporting..")
    for i, pid in ipairs(players) do
        doSendMagicEffect(config.entry[i], CONST_ME_POFF)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
    end
  
    print("All players were teleported.")
    doTransformItem(item.uid, item.itemid + 1)
    return true
end
Doesnt appear anything on my console, and I cant even pull the lever. Nothing happens when I try pulling it.

Do I have to put something on lever action id also? I have number 0 right now
 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,487
Doesnt appear anything on my console, and I cant even pull the lever. Nothing happens when I try pulling it.

Do I have to put something on lever action id also? I have number 0 right now
Do you have multiple items on your map with the same UniqueId?
If there are multiple, only the first one loaded in the map will work.

Otherwise, check your console more closely, and see if there is an error related to this script upon start-up.
 
OP
OP
P

pepito999

New Member
Joined
Jul 19, 2011
Messages
33
Solutions
1
Reaction score
0
Do you have multiple items on your map with the same UniqueId?
If there are multiple, only the first one loaded in the map will work.

Otherwise, check your console more closely, and see if there is an error related to this script upon start-up.
Thank you, finally it worked. But since it doesnt spawn demons I need to use the other one I found but need to eliminate the spawn of walls and stones. I eliminated some of the code, but I am new to this and cant make it work.
Post automatically merged:

Got it working with this new script I found from the user Frankit0. Thank you.



Lua:
-- Annihilator by Shawak v2.1

        -- CONFIG --

        local room = {     -- room with demons
        fromX = 33219,
        fromY = 31657,
        fromZ = 13,
        --------------
        toX = 33222,
        toY = 31661,
        toZ = 13
        }

        local monster_pos = {
        [1] = {pos = {33219, 31657, 13}, monster = "Demon"},
        [2] = {pos = {33221, 31657, 13}, monster = "Demon"},
        [3] = {pos = {33220, 31661, 13}, monster = "Demon"},
        [4] = {pos = {33222, 31661, 13}, monster = "Demon"},
        [5] = {pos = {33223, 31659, 13}, monster = "Demon"},
        [6] = {pos = {33224, 31659, 13}, monster = "Demon"}
        }

        local players_pos = {
        {x = 33222, y =31671, z = 13, stackpos = 253},
        {x = 33223, y =31671, z = 13, stackpos = 253},
        {x = 33224, y =31671, z = 13, stackpos = 253},
        {x = 33225, y =31671, z = 13, stackpos = 253}
        }

        local new_player_pos = {
        {x = 33219, y = 31659, z = 13},
        {x = 33220, y = 31659, z = 13},
        {x = 33221, y = 31659, z = 13},
        {x = 33222, y = 31659, z = 13}
        }

        local playersOnly = "no"
        local questLevel = 101

        ------------------------------------------------------
        --- CONFIG END ---------------------------------------
        ------------------------------------------------------

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local all_ready, monsters, player, level = 0, 0, {}, 0
        if item.itemid == 1945 then
                for i = 1, #players_pos do
                        table.insert(player, 0)
                end
                for i = 1, #players_pos do
                        player[i] = getThingfromPos(players_pos[i])
                        if player[i].itemid > 0 then
                                if string.lower(playersOnly) == "yes" then
                                        if isPlayer(player[i].uid) == TRUE then
                                                all_ready = all_ready+1
                                        else
                                                monsters = monsters+1
                                        end
                                else
                                        all_ready = all_ready+1
                                end
                        end
                end
                if all_ready == #players_pos then
                        for i = 1, #players_pos do
                                player[i] = getThingfromPos(players_pos[i])
                                if isPlayer(player[i].uid) == TRUE then
                                        if getPlayerLevel(player[i].uid) >= questLevel then
                                                level = level+1
                                        end
                                else
                                        level = level+1
                                end
                        end
                        if level == #players_pos then
                                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                                        for _, area in pairs(monster_pos) do
                                                        doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
                                        end
                                        for i = 1, #players_pos do
                                                doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                                                doTeleportThing(player[i].uid, new_player_pos[i], FALSE)
                                                doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                                                doTransformItem(item.uid,1946)
                                        end
                                else
                                        doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
                                end
                        else
                                doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
                        end
                else
                        doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.")
                end
        elseif item.itemid == 1946 then
                local player_room = 0
                for x = room.fromX, room.toX do
                        for y = room.fromY, room.toY do
                                for z = room.fromZ, room.toZ do
                                        local pos = {x=x, y=y, z=z,stackpos = 253}
                                        local thing = getThingfromPos(pos)
                                        if thing.itemid > 0 then
                                                if isPlayer(thing.uid) == TRUE then
                                                        player_room = player_room+1
                                                end
                                        end
                                end
                        end
                end
                if player_room >= 1 then
                        doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")         
                elseif player_room == 0 then
                        for x = room.fromX, room.toX do
                                for y = room.fromY, room.toY do
                                        for z = room.fromZ, room.toZ do
                                                local pos = {x=x, y=y, z=z,stackpos = 253}
                                                local thing = getThingfromPos(pos)
                                                if thing.itemid > 0 then
                                                        doRemoveCreature(thing.uid)
                                                end
                                        end
                                end
                        end
                        doTransformItem(item.uid,1945)
                end
        end
        return TRUE
end
 
Last edited:
Solution
Top