• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Annihilator

MaR0

Banned User
Joined
Apr 16, 2018
Messages
272
Solutions
3
Reaction score
29
Hello ALL ! I was wondering if I could make some changes but failed because I was a beginner at lua.
I want to edit annihilator to make it with 4 players every player stand at tile with specific vocation type and different level also the 4 players must have money to move the stick
Also I do not want additions of monsters spawns like at the script
All I need is a process of moving from one place to another only with specific requirements and specific Vocations.
here is the script and some photo to explain.
XML:
<action actionid="5000" event="script" value="quests/anni.lua"/>
anni.lua:-
LUA:
local config = {
        daily = "no", -- allow only one team to enter per day? (like in global Tibia)
        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
Capture.png

thanks
 
Solution
X
Hello ALL ! I was wondering if I could make some changes but failed because I was a beginner at lua.
I want to edit annihilator to make it with 4 players every player stand at tile with specific vocation type and different level also the 4 players must have money to move the stick
Also I do not want additions of monsters spawns like at the script
All I need is a process of moving from one place to another only with specific requirements and specific Vocations.
here is the script and some photo to explain.
XML:
<action actionid="5000" event="script" value="quests/anni.lua"/>
anni.lua:-
LUA:
local config = {
        daily = "no", -- allow only one team to enter per day? (like in global Tibia)
        level = 100,
        storage =...
Hello ALL ! I was wondering if I could make some changes but failed because I was a beginner at lua.
I want to edit annihilator to make it with 4 players every player stand at tile with specific vocation type and different level also the 4 players must have money to move the stick
Also I do not want additions of monsters spawns like at the script
All I need is a process of moving from one place to another only with specific requirements and specific Vocations.
here is the script and some photo to explain.
XML:
<action actionid="5000" event="script" value="quests/anni.lua"/>
anni.lua:-
LUA:
local config = {
        daily = "no", -- allow only one team to enter per day? (like in global Tibia)
        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
Capture.png

thanks
Not tested.
LUA:
local config = {
    {vocation_required = {1, 5}, level = 400000, item_required = 11111, item_amount = 1,  stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}},
    {vocation_required = {2, 6}, level = 400000, item_required = 11111, item_amount = 5,  stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}},
    {vocation_required = {3, 7}, level = 400000, item_required = 11111, item_amount = 10, stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}},
    {vocation_required = {4, 8}, level = 500000, item_required = 11111, item_amount = 3,  stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        doTransformItem(item.uid, item.itemid + 1)
    else
        doTransformItem(item.uid, item.itemid - 1)
    end
   
    local players = {}
    for i = 1, #config do
        local passed_requirements = 1
        local pid = getTopCreature(config[i].stand_pos).uid
        if isPlayer(pid) then
            if not isInArray(config[i].vocation_required, getPlayerVocation(pid)) then
                passed_requirements = 0
            end
            if getPlayerLevel(pid) < config[i].level then
                passed_requirements = 0
            end
            if getPlayerItemCount(pid, config[i].item_required) < config[i].item_amount then
                passed_requirements = 0
            end
        else
            passed_requirements = 0
        end
        if passed_requirements == 1 then
            table.insert(players, pid)
            doSendMagicEffect(config[i].stand_pos, CONST_ME_MAGIC_GREEN)
        else
            doSendMagicEffect(config[i].stand_pos, CONST_ME_MAGIC_RED)
        end
    end
   
    if #players == #config then
        for i = 1, #config do
            doPlayerRemoveItem(players[i], config[i].item_required, config[i].item_amount)
            doTeleportThing(players[i], config[i].destination, false)
            doSendMagicEffect(config[i].destination, CONST_ME_TELEPORT)
        end
    end
    return true
end
 
Solution
Not tested.
LUA:
local config = {
    {vocation_required = {1, 5}, level = 400000, item_required = 11111, item_amount = 1,  stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}},
    {vocation_required = {2, 6}, level = 400000, item_required = 11111, item_amount = 5,  stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}},
    {vocation_required = {3, 7}, level = 400000, item_required = 11111, item_amount = 10, stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}},
    {vocation_required = {4, 8}, level = 500000, item_required = 11111, item_amount = 3,  stand_pos = {x = 1000, y = 1000, z = 7}, destination = {x = 1000, y = 1000, z = 7}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        doTransformItem(item.uid, item.itemid + 1)
    else
        doTransformItem(item.uid, item.itemid - 1)
    end
  
    local players = {}
    for i = 1, #config do
        local passed_requirements = 1
        local pid = getTopCreature(config[i].stand_pos).uid
        if isPlayer(pid) then
            if not isInArray(config[i].vocation_required, getPlayerVocation(pid)) then
                passed_requirements = 0
            end
            if getPlayerLevel(pid) < config[i].level then
                passed_requirements = 0
            end
            if getPlayerItemCount(pid, config[i].item_required) < config[i].item_amount then
                passed_requirements = 0
            end
        else
            passed_requirements = 0
        end
        if passed_requirements == 1 then
            table.insert(players, pid)
            doSendMagicEffect(config[i].stand_pos, CONST_ME_MAGIC_GREEN)
        else
            doSendMagicEffect(config[i].stand_pos, CONST_ME_MAGIC_RED)
        end
    end
  
    if #players == #config then
        for i = 1, #config do
            doPlayerRemoveItem(players[i], config[i].item_required, config[i].item_amount)
            doTeleportThing(players[i], config[i].destination, false)
            doSendMagicEffect(config[i].destination, CONST_ME_TELEPORT)
        end
    end
    return true
end
works perfectly, thanks mate !
 
Back
Top