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

TFS 1.X+ problem migration from tfs 0.4 to 1.2

Diarreamental

Banned User
Joined
Jul 6, 2015
Messages
463
Solutions
1
Reaction score
85
Hello

Guys i have problem with boat npcs. I use these npc files on my 0.4 datapack and they works with no problem, i migrated files and with few changes everything seems to works ok, but the problem is that the function " bring me to " isn't working anymore. If i use this phrase a tp effect will appear on the character but the player isn't being teleported to X city at all.
i have no errors on console either

edit:
Also at movements i can't figure out why i have this error
Code:
MoveEvent::loadFunction] Function "" does not exist.


edit2: problem with npcss was solved i forgot to add functions into lib folder


Captain Bluebeard.lua
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local voices = { {text = 'Passages to Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay and Svargrond.'} } npcHandler:addModule(VoiceModule:new(voices)) -- Travel local function addTravelKeyword(keyword, cost, destination, action) local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to ' .. titleCase(keyword) .. ' for |TRAVELCOST|?', cost = cost, discount = 'postman'}) travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = cost, discount = 'postman', destination = destination}, nil, action) travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true}) keywordHandler:addKeyword({"bring me to "..keyword}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = cost, discount = 'postman', destination = destination, onlyFocus = false}, nil, action) end addTravelKeyword('carlin', 110, Position(32387, 31820, 6), function(player) if player:getStorageValue(2005) == 1 then player:setStorageValue(2005, 2) end end) addTravelKeyword('ab\'dendriel', 130, Position(32734, 31668, 6)) addTravelKeyword('edron', 160, Position(33175, 31764, 6)) addTravelKeyword('venore', 170, Position(32954, 32022, 6)) addTravelKeyword('port hope', 160, Position(32527, 32784, 6)) addTravelKeyword('svargrond', 180, Position(32341, 31108, 6)) addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6)) -- Kick keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}}) keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Captain Bluebear from the Royal Tibia Line.'}) keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'}) keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'}) keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'line'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'company'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'route'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, text = 'We can transport everything you want.'}) keywordHandler:addKeyword({'passenger'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to welcome you on board.'}) keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay or Svargrond?'}) keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay or Svargrond?'}) keywordHandler:addKeyword({'town'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay or Svargrond?'}) keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay or Svargrond?'}) keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay or Svargrond?'}) keywordHandler:addKeyword({'go'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay or Svargrond?'}) keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay or Svargrond?'}) keywordHandler:addKeyword({'ice'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'senja'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'folda'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'vega'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'}) keywordHandler:addKeyword({'darama'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'}) keywordHandler:addKeyword({'ghost'}, StdModule.say, {npcHandler = npcHandler, text = 'Many people who sailed to Darashia never returned because they were attacked by a ghostship! I\'ll never sail there!'}) keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Thais. Where do you want to go?'}) npcHandler:setMessage(MESSAGE_GREET, 'Welcome on board, |PLAYERNAME|. Where can I sail you today?') npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye. Recommend us if you were satisfied with our service.') npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye then.') npcHandler:addModule(FocusModule:new())
 
Last edited:
Solution
If you put 100, It will transform the ground to hole id 489.
What hole you are expecting it to be transformed to? I can't recall what desert/sand hidden holes transform to.
So you only have now function doesn't exist error?
That is because you copied lines from 0.4 XML file to 1.2 XML file
in TFS 1.2 there's no more event="script", event="function" or value="something.lua"
You'll have to add like this
function="onDeEquipItem" or script="name.lua"
 
oh thanks i forgot to change
Code:
value="
to
Code:
script="
" in few parts

solved
Post automatically merged:

@M0ustafa can you help me? i can't get this working. It's related to open hole into sand. I changed the AID from 55555 to 101 also changed the lua files many times, scarabs appears, scarabs coins too. But i can't open a hole into the sand with the AID 101 or 55555.

help please & thanks

actions/lib/actions.lua
Code:
function onUseShovel(player, item, fromPosition, target, toPosition)
    local targetId = target.itemid, target.actionid
    if table.contains(others, targetId) then
        target:transform(targetId + 1)
        target:decay()

        return true
    end

    if toPosition.x == CONTAINER_POSITION then
        return false
    end

    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end

    local groundId = ground:getId()
    if table.contains(holes, groundId) then
        ground:transform(groundId + 1)
        ground:decay()

        toPosition.z = toPosition.z + 1
        tile:relocateTo(toPosition)
    elseif groundId == 231 then
        local randomValue = math.random(1, 100)
        if randomValue == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif randomValue > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
        return false
    end

    return true
end
actions/tools/shovel.lua
Code:
local holes = {468, 481, 483}
function onUse(player, item, fromPosition, target, toPosition)
    if toPosition.x == CONTAINER_POSITION then
        return false
    end

    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end

    local groundId = ground:getId()
    if isInArray(holes, groundId) then
        ground:transform(groundId + 1)
        ground:decay()

        toPosition.z = toPosition.z + 1
        tile:relocateTo(toPosition)
    elseif groundId == 231 then
        local randomValue = math.random(1, 100)
        if randomValue == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif randomValue > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
        return false
    end

    return true
end
 
Last edited:
Add this instead of your function onUseShovel
LUA:
function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId, targetActionId = target.itemid, target.actionid
    if isInArray(holes, targetId) then
        target:transform(targetId + 1)
        target:decay()

    elseif isInArray({231, 9059}, targetId) then
        local rand = math.random(100)
        if target.actionid == 100 and rand <= 20 then
            target:transform(489)
            target:decay()
        elseif rand == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)

    -- Wrath of the emperor quest
    elseif targetId == 351 and targetActionId == 8024 then
        player:addItem(12297, 1)
        player:say("You dig out a handful of earth from this sacred place.", TALKTYPE_MONSTER_SAY)

    -- RookgaardTutorialIsland
    elseif targetId == 8579 and player:getStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage) < 20 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug a hole! Walk onto it as long as it is open to jump down into the forest cave.')
        player:setStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage, 19)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALARROW)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALSQUARE)
        target:transform(469)
        addEvent(revertItem, 30 * 1000, toPosition, 469, 8579)

    -- Gravedigger Quest
    elseif targetActionId == 4654 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission49) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission50) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You found a piece of the scroll. You pocket it quickly.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission50, 1)

    elseif targetActionId == 4668 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission67) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission68) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'A torn scroll piece emerges. Probably gnawed off by rats.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission68, 1)

    -- ???
    elseif targetActionId == 50118 then
        local wagonItem = Tile(Position(32717, 31492, 11)):getItemById(7131)
        if wagonItem then
            Game.createItem(8749, 1, wagonItem:getPosition())
            toPosition:sendMagicEffect(CONST_ME_POFF)
        end

    elseif targetId == 8749 then
        local coalItem = Tile(Position(32699, 31492, 11)):getItemById(8749)
        if coalItem then
            coalItem:remove()
            toPosition:sendMagicEffect(CONST_ME_POFF)

            local crucibleItem = Tile(Position(32699, 31494, 11)):getItemById(8642)
            if crucibleItem then
                crucibleItem:setActionId(50119)
            end
        end

    elseif isInArray({9632, 20230}, targetId) then
        if player:getStorageValue(Storage.SwampDiggingTimeout) >= os.time() then
            return false
        end

        local config = { {from = 1, to = 39, itemId = 2817}, {from = 40, to = 79, itemId = 2145}, {from = 80, to = 100, itemId = 20138} }
        local chance = math.random(100)

        for i = 1, #config do
            local randItem = config[i]
            if chance >= randItem.from and chance <= randItem.to then
                player:addItem(randItem.itemId, 1)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug up a ' .. ItemType(randItem.itemId):getName() .. '.')
                player:setStorageValue(Storage.SwampDiggingTimeout, os.time() + 604800)
                toPosition:sendMagicEffect(CONST_ME_GREEN_RINGS)
                break
            end
        end

    elseif targetId == 103 and targetActionId == 4205 then
        if player:getStorageValue(Storage.TibiaTales.IntoTheBonePit) ~= 1 then
            return false
        end

        local remains = Game.createItem(2248, 1, toPosition)
        if remains then
            remains:setActionId(4206)
        end
        toPosition:sendMagicEffect(CONST_ME_HITAREA)
        addEvent(removeRemains, 60000, toPosition)

    elseif targetId == 22674 then
        if not player:removeItem(5091, 1) then
            return false
        end

        target:transform(5731)
        target:decay()
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
        return false
    end

    return true
end
and this instead of your shovel.lua
LUA:
local holes = {468, 481, 483, 7932}

local function revertHole(toPosition)
    local tile = toPosition:getTile()
    if tile then
        local thing = tile:getItemById(469)
        if thing then
            thing:transform(8579)
        end
    end
end

local function removeRemains(toPosition)
    local item = Tile(toPosition):getItemById(2248)
    if item then
        item:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray(holes, target.itemid) then
        target:transform(target.itemid + 1)
        target:decay()
    elseif target.itemid == 231 or target.itemid == 9059 then
        local rand = math.random(100)
        if target.actionid == 100 and rand <= 20 then
            target:transform(489)
            target:decay()
        elseif rand == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)
    -- Wrath of the emperor quest
    elseif target.itemid == 351 and target.actionid == 8024 then
        player:addItem(12297, 1)
        player:say("You dig out a handful of earth from this sacred place.", TALKTYPE_MONSTER_SAY)
    -- RookgaardTutorialIsland
    elseif target.itemid == 8579 and player:getStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage) < 20 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug a hole! Walk onto it as long as it is open to jump down into the forest cave.')
        player:setStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage, 19)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALARROW)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALSQUARE)
        target:transform(469)
        addEvent(revertHole, 30 * 1000, toPosition)
    -- Gravedigger Quest
    elseif target.actionid == 4654 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission49) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission50) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You found a piece of the scroll. You pocket it quickly.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission50, 1)
    elseif target.actionid == 4668 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission67) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission68) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'A torn scroll piece emerges. Probably gnawed off by rats.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission68, 1)
    -- ???
    elseif target.actionid == 50118 then
        local position = Position(32717, 31492, 11)
        if Tile(position):getItemById(7131) then
            Game.createItem(8749, 1, position)
            toPosition:sendMagicEffect(CONST_ME_POFF)
        end
    elseif target.itemid == 8749 then
        local tile = Tile(Position(32699, 31492, 11))
        if tile:getItemById(8749) then
            tile:getItemById(8749):remove()
            toPosition:sendMagicEffect(CONST_ME_POFF)
            Tile(Position(32699, 31494, 11)):getItemById(8642):setActionId(50119)
        end
    elseif isInArray({9632, 20230}, target.itemid) then
        if player:getStorageValue(Storage.SwampDiggingTimeout) >= os.time() then
            return false
        end

        local config, chance = {
            {from = 1, to = 39, itemId = 2817},
            {from = 40, to = 79, itemId = 2145},
            {from = 80, to = 100, itemId = 20138}
        }, math.random(100)

        for i = 1, #config do
            local randItem = config[i]
            if chance >= randItem.from and chance <= randItem.to then
                player:addItem(randItem.itemId, 1)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug up a ' .. ItemType(randItem.itemId):getName() .. '.')
                player:setStorageValue(Storage.SwampDiggingTimeout, os.time() + 604800)
                toPosition:sendMagicEffect(CONST_ME_GREEN_RINGS)
                break
            end
        end
    elseif target.itemid == 103 then
        if target.actionid == 4205 then
            if player:getStorageValue(Storage.TibiaTales.IntoTheBonePit) ~= 1 then
                return false
            end

            local remains = Game.createItem(2248, 1, toPosition)
            if remains then
                remains:setActionId(4206)
            end
            toPosition:sendMagicEffect(CONST_ME_HITAREA)
            addEvent(removeRemains, 60000, toPosition)
        end
    elseif target.itemid == 22674 then
        if not player:removeItem(5091, 1) then
            return false
        end

        target:transform(5731)
        target:decay()
        toPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
If you have other issues create different thread for every issue, so its easier for others who have same issue to find and other members to help you.
 
Add this instead of your function onUseShovel
LUA:
function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId, targetActionId = target.itemid, target.actionid
    if isInArray(holes, targetId) then
        target:transform(targetId + 1)
        target:decay()

    elseif isInArray({231, 9059}, targetId) then
        local rand = math.random(100)
        if target.actionid == 100 and rand <= 20 then
            target:transform(489)
            target:decay()
        elseif rand == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)

    -- Wrath of the emperor quest
    elseif targetId == 351 and targetActionId == 8024 then
        player:addItem(12297, 1)
        player:say("You dig out a handful of earth from this sacred place.", TALKTYPE_MONSTER_SAY)

    -- RookgaardTutorialIsland
    elseif targetId == 8579 and player:getStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage) < 20 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug a hole! Walk onto it as long as it is open to jump down into the forest cave.')
        player:setStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage, 19)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALARROW)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALSQUARE)
        target:transform(469)
        addEvent(revertItem, 30 * 1000, toPosition, 469, 8579)

    -- Gravedigger Quest
    elseif targetActionId == 4654 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission49) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission50) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You found a piece of the scroll. You pocket it quickly.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission50, 1)

    elseif targetActionId == 4668 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission67) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission68) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'A torn scroll piece emerges. Probably gnawed off by rats.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission68, 1)

    -- ???
    elseif targetActionId == 50118 then
        local wagonItem = Tile(Position(32717, 31492, 11)):getItemById(7131)
        if wagonItem then
            Game.createItem(8749, 1, wagonItem:getPosition())
            toPosition:sendMagicEffect(CONST_ME_POFF)
        end

    elseif targetId == 8749 then
        local coalItem = Tile(Position(32699, 31492, 11)):getItemById(8749)
        if coalItem then
            coalItem:remove()
            toPosition:sendMagicEffect(CONST_ME_POFF)

            local crucibleItem = Tile(Position(32699, 31494, 11)):getItemById(8642)
            if crucibleItem then
                crucibleItem:setActionId(50119)
            end
        end

    elseif isInArray({9632, 20230}, targetId) then
        if player:getStorageValue(Storage.SwampDiggingTimeout) >= os.time() then
            return false
        end

        local config = { {from = 1, to = 39, itemId = 2817}, {from = 40, to = 79, itemId = 2145}, {from = 80, to = 100, itemId = 20138} }
        local chance = math.random(100)

        for i = 1, #config do
            local randItem = config[i]
            if chance >= randItem.from and chance <= randItem.to then
                player:addItem(randItem.itemId, 1)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug up a ' .. ItemType(randItem.itemId):getName() .. '.')
                player:setStorageValue(Storage.SwampDiggingTimeout, os.time() + 604800)
                toPosition:sendMagicEffect(CONST_ME_GREEN_RINGS)
                break
            end
        end

    elseif targetId == 103 and targetActionId == 4205 then
        if player:getStorageValue(Storage.TibiaTales.IntoTheBonePit) ~= 1 then
            return false
        end

        local remains = Game.createItem(2248, 1, toPosition)
        if remains then
            remains:setActionId(4206)
        end
        toPosition:sendMagicEffect(CONST_ME_HITAREA)
        addEvent(removeRemains, 60000, toPosition)

    elseif targetId == 22674 then
        if not player:removeItem(5091, 1) then
            return false
        end

        target:transform(5731)
        target:decay()
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
        return false
    end

    return true
end
and this instead of your shovel.lua
LUA:
local holes = {468, 481, 483, 7932}

local function revertHole(toPosition)
    local tile = toPosition:getTile()
    if tile then
        local thing = tile:getItemById(469)
        if thing then
            thing:transform(8579)
        end
    end
end

local function removeRemains(toPosition)
    local item = Tile(toPosition):getItemById(2248)
    if item then
        item:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray(holes, target.itemid) then
        target:transform(target.itemid + 1)
        target:decay()
    elseif target.itemid == 231 or target.itemid == 9059 then
        local rand = math.random(100)
        if target.actionid == 100 and rand <= 20 then
            target:transform(489)
            target:decay()
        elseif rand == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)
    -- Wrath of the emperor quest
    elseif target.itemid == 351 and target.actionid == 8024 then
        player:addItem(12297, 1)
        player:say("You dig out a handful of earth from this sacred place.", TALKTYPE_MONSTER_SAY)
    -- RookgaardTutorialIsland
    elseif target.itemid == 8579 and player:getStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage) < 20 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug a hole! Walk onto it as long as it is open to jump down into the forest cave.')
        player:setStorageValue(Storage.RookgaardTutorialIsland.tutorialHintsStorage, 19)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALARROW)
        Position(32070, 32266, 7):sendMagicEffect(CONST_ME_TUTORIALSQUARE)
        target:transform(469)
        addEvent(revertHole, 30 * 1000, toPosition)
    -- Gravedigger Quest
    elseif target.actionid == 4654 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission49) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission50) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You found a piece of the scroll. You pocket it quickly.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission50, 1)
    elseif target.actionid == 4668 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission67) == 1 and player:getStorageValue(Storage.GravediggerOfDrefia.Mission68) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'A torn scroll piece emerges. Probably gnawed off by rats.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:addItem(21250, 1)
        player:setStorageValue(Storage.GravediggerOfDrefia.Mission68, 1)
    -- ???
    elseif target.actionid == 50118 then
        local position = Position(32717, 31492, 11)
        if Tile(position):getItemById(7131) then
            Game.createItem(8749, 1, position)
            toPosition:sendMagicEffect(CONST_ME_POFF)
        end
    elseif target.itemid == 8749 then
        local tile = Tile(Position(32699, 31492, 11))
        if tile:getItemById(8749) then
            tile:getItemById(8749):remove()
            toPosition:sendMagicEffect(CONST_ME_POFF)
            Tile(Position(32699, 31494, 11)):getItemById(8642):setActionId(50119)
        end
    elseif isInArray({9632, 20230}, target.itemid) then
        if player:getStorageValue(Storage.SwampDiggingTimeout) >= os.time() then
            return false
        end

        local config, chance = {
            {from = 1, to = 39, itemId = 2817},
            {from = 40, to = 79, itemId = 2145},
            {from = 80, to = 100, itemId = 20138}
        }, math.random(100)

        for i = 1, #config do
            local randItem = config[i]
            if chance >= randItem.from and chance <= randItem.to then
                player:addItem(randItem.itemId, 1)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You dug up a ' .. ItemType(randItem.itemId):getName() .. '.')
                player:setStorageValue(Storage.SwampDiggingTimeout, os.time() + 604800)
                toPosition:sendMagicEffect(CONST_ME_GREEN_RINGS)
                break
            end
        end
    elseif target.itemid == 103 then
        if target.actionid == 4205 then
            if player:getStorageValue(Storage.TibiaTales.IntoTheBonePit) ~= 1 then
                return false
            end

            local remains = Game.createItem(2248, 1, toPosition)
            if remains then
                remains:setActionId(4206)
            end
            toPosition:sendMagicEffect(CONST_ME_HITAREA)
            addEvent(removeRemains, 60000, toPosition)
        end
    elseif target.itemid == 22674 then
        if not player:removeItem(5091, 1) then
            return false
        end

        target:transform(5731)
        target:decay()
        toPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
If you have other issues create different thread for every issue, so its easier for others who have same issue to find and other members to help you.
which id should i place in the sand in order to open hole example for tombs etc?

by the way thanks for the scripts
 
If you put 100, It will transform the ground to hole id 489.
What hole you are expecting it to be transformed to? I can't recall what desert/sand hidden holes transform to.
 
Solution
Back
Top