• 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 Clones Dungeon [Quest]

Carlitos Flow

Developer (lvl*1)
Joined
Mar 2, 2011
Messages
156
Solutions
4
Reaction score
10
Good day guys, well, im working on a script and need some help please... like this video (of course i will do for tibia):


*Im Using T.F.S 0.3.6
*When someone dead the team is kicked from the quest, and the team need wait 24hrs to try again.
*I will try use "boxes" because tibia doesn't have that "green containers.
*When the team kill all monsters (all boxes break) they finish the quest and add exp, and ofc the reward.
*If the team done the quest, they must wait 30 days for do the quest again.
*The "entrance" can be like an anihilator (4 tiles) and a lever, i have already added this on the script than im editing.
*From the boxes (green containers) when you broke the box will born a monster random [2nd script]. If im wrong you can say me please.
*When the team kill all monsters and they done the quest, this quest must reset automatically for another team than want to do. (Create the boxes again on the map). [I don't know how i can do this on the script]


*I Know, i don't have a good english and im new trying to learn lua, but this is than i did done of the script, and i really hope your help guys, thank guy.

actions/lever.lua
Code:
local playerA={
    {x=1154, y=1582, z=7},
    {x=1154, y=1581, z=7},
    {x=1154, y=1580, z=7},
    {x=1154, y=1579, z=7},
}
local playerB={
    {x=1154, y=1582, z=8},
    {x=1153, y=1582, z=8},
    {x=1152, y=1582, z=8},
    {x=1151, y=1582, z=8},
}
 local c = {
    Storage = 10540, -- Number Storage
    Tiempo = 30, -- Days for next quest
    Premio = { -- {ID item, how many items},
        {8309, 3}, -- Nail x3
        {10570, 2}, -- Which Hat x2
    },
  }

  local globalExhaust = {
    get = function (storage)
      local exhaust = getGlobalStorageValue(storage)
        if(exhaust > 0) then
          local left = exhaust - os.time()
            if(left >= 0) then
              return left
            end
        end
      return false
    end,
    set = function (storage, time)
        setGlobalStorageValue(storage, os.time() + time)
    end
  }

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local t = {}
    if item.itemid == 1945 then
        for i = 1, 4 do
            t[i]=getTopCreature(playerA[i]).uid
            if t[i] == 0 or not isPlayer(t[i]) then
                return doPlayerSendCancel(cid, 'You need 4 players for this quest.')
            elseif getPlayerLevel(t[i]) < 100 then
                return doPlayerSendCancel(cid, 'All players need to have level 100 or higher.')
            end
        end
 
    ---- When someone team is doing
          starting={x=58, y=1112, z=7, stackpos=253}
          checking={x=starting.x, y=starting.y, z=starting.z, stackpos=starting.stackpos}
          ending={x=142, y=1288, z=7, stackpos=253}
          players=0
          checking.x=checking.x+1
          if checking.x>ending.x then
          checking.x=starting.x
          checking.y=checking.y+1
       end

       local accID, nIP = getPlayerAccountId(cid), getPlayerIp(cid)
       local Belero = {
       [c.Storage+1] = {accID},
       [c.Storage+2] = {nIP},
       }
  
      ---- When start Quest
        for i = 1, #t do
            doTeleportThing(t[i], playerB[i])
            doSendMagicEffect(playerA[i], CONST_ME_POFF)
            doSendMagicEffect(playerB[i], CONST_ME_ENERGYAREA)
        end
    elseif players > 0 then
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Please wait for the team currently fighting to finish.')
     return false
     end
    elseif accID == getGlobalStorageValue(c.Storage+1) or nIP == getGlobalStorageValue(c.Storage+2) then
      doPlayerSendCancel(cid, (globalExhaust.get(c.Storage) > 0 and "You must wait " .. timeString(globalExhaust.get(c.Storage)) .. " days to do this quest again." or nil))
          return true
       elseif
        for k, v in pairs(Belero) do
            setGlobalStorageValue(k, v[1])
            globalExhaust.set(c.Storage, c.Tiempo * 24 * 60 * 60)
            addEvent(setGlobalStorageValue, c.Tiempo * 24 * 60 * 60 * 1000, k, -1)
        end
        for _, v in ipairs(c.Premio) do
            doPlayerAddItem(cid, v[1], v[2])
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have already done your quest this month.!")
        return true
    end

action/box.lua
Code:
local summon={
    {'Dragon'},
    {'Demon'},
    {'Dragon Lord'},
    {'Fury'}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == xxxx then --- item from the box
    for i = 1, 4 #summon do
            doCreateMonster[math.random(unpack(summon[i]))]
            doRemoveItem(xxxx.uid, 1)  --- remove the box
        end
     end
 end
King Regards!
 
Last edited:
For all of the boxes on your map, say, itemid == 1738 and put actionid == 1000 then do in actions
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   doTransformItem(item, 2250)
   doSummonCreature(monster,fromPosition)
   setGlobalStorageValue(key,getGlobalStorageValue(key)+1)
end
then do
Lua:
for i, box in ipairs(boxes) do
    doTransformItem(box, __boxitemid__)
end
setGlobalStorageValue(key,0)
when player dies or quest is completed
 
Last edited:
When I back to house I test all, im on cel now im no seeing good, @Aled but Also remember the will got the global storage after kill the monster. Like this?
Actions/box.lua
Lua:
local summon={
    {'Dragon'},
    {'Demon'},
    {'Dragon Lord'},
    {'Fury'}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.actionid == 1000 then -- Change itemid and actionid
   local i = math.random(#summon)
       doRemoveItem(item.uid, 1)
      doCreateMonster(summon[i][1], toPosition)
      doSendMagicEffect(toPosition, CONST_ME_TELEPORT)
   end
   return true
end

creaturescripts/endquest.lua
Lua:
dofile('data/actions/box.lua')

function onKill(cid, target)
local config = {
    ["summon[i]"] = {amount = 1, storage = 26700}
}

local monster = config[getCreatureName(target):lower()]

    if(isPlayer(target)) or not monster then
        return true
    end

    if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage) +1) < monster.amount then  
        setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
    end
    if (getPlayerStorageValue(cid, monster.storage) +1) == monster.amount then
        setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, +1)
    end
    return TRUE
end
 
Imo in that case better to use that "shit" items:
3a1831cf07e2cecf32d0b5214a75d3f2.png

Lua:
    local boxes = {
       {x = 1000, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1001, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1002, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1003, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1004, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1005, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
   }
   local container_id_new = 1428
   local container_id_broken = 1427
   local actionid = 1000
   local storage_amount_of_opened_boxes = 1001
   local key = 1000
   for i = 1, #boxes do
       if getThingFromPos(boxes[i]).itemid == container_id_broken then
           doTransformItem(getThingFromPos(boxes[i]).uid, container_id_new)
           doSetItemActionId(getThingFromPos(boxes[i]).uid, actionid)
       end
   end
   setGlobalStorageValue(key, 0)
   setGlobalStorageValue(storage_amount_of_opened_boxes, 0)

Lua:
local summon = {
       {'Dragon'},
       {'Demon'},
       {'Dragon Lord'},
       {'Fury'}
   }
   local container_id_broken = 1427
   local actionid = 1000
   local storage_amount_of_opened_boxes = 1001
  
   function onUse(cid, item, fromPosition, itemEx, toPosition)
       if item.actionid == actionid then -- Change itemid and actionid
           local i = math.random(#summon)
           local pos = getClosestFreeTile(cid, toPosition)
           doTransformItem(item.uid, 1427)
           doSetItemActionId(item.uid, 0)
           doCreateMonster(summon[i][1], pos)
           doSendMagicEffect(pos, CONST_ME_TELEPORT)
           setGlobalStorageValue(storage_amount_of_opened_boxes, tonumber(getGlobalStorageValue(storage_amount_of_opened_boxes) + 1))
       end
       return true
   end
 
Last edited:
Now my creaturescript : (i want it script take +1 of storage when i kill 1 monster, until (+10) getStorageValue(43600,10) for done the quest. Error on console: <luaGetCreatureStorage> Creature not found
Lua:
function resetQuest()
  local boxes = {
       {x = 996, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 998, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1000, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1002, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1004, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 996, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 998, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1000, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1002, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1004, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
   }
   
   local container_id_new = 1428
   local container_id_broken = 1427
   local actionid = 43600
   local storage_amount_of_opened_boxes = 1001
   for i = 1, #boxes do
   
       if getThingFromPos(boxes[i]).itemid == container_id_broken then
           doTransformItem(getThingFromPos(boxes[i]).uid, container_id_new)
           doSetItemActionId(getThingFromPos(boxes[i]).uid, actionid)
       end
   end
return TRUE
end


function onKill(cid, target)
local config = {
    ["dragon"] = {storage = 1050},
    ["dragon lord"] = {storage = 1050}
}

local monster = config[getCreatureName(target):lower()]


    if(isPlayer(target)) or not monster then 
    return TRUE
    end
       
    if getGlobalStorageValue(cid, monster.storage) >= 0 then  
     setGlobalStorageValue(cid, monster.storage, getGlobalStorageValue(cid, monster.storage) +1)
    end

   --- end quest --
    if getPlayerStorageValue(cid,1050,0) and getGlobalStorageValue(cid, 2050,10) then
    setPlayerStorageValue(cid,1050,-1)
    setGlobalStorageValue(cid,2050,-1)
    doPlayerTeleportThing(cid,{x=1000, y=1000, z=7}, false)
    resetQuest()
end
return TRUE
end
 
Lua:
getGlobalStorageValue(cid,2050,10)
remove all "cid," from globalStorages
Lua:
getPlayerStorageValue(cid,1050) == 0
getGlobalStorageValue(2050) == 10
 
Lua:
getGlobalStorageValue(cid,2050,10)
remove all "cid," from globalStorages
Lua:
getPlayerStorageValue(cid,1050) == 0
getGlobalStorageValue(2050) == 10

all working, but one question, i only can set globalstorages right? because if i try only storage all team using "setplayerstorage"doesnt works:/ Also here the bug of now with globalstorages: (when the team kill the 10 monster, they will be tp to a position and got the reward, and storage of 31 days for do again. the problem is: data/live/032-position 'toPosition' <a nil value> in function 'isInArea' [isIn Arena works on other quest, idk what happen)

Lua:
function resetQuest()
  local boxes = {
       {x = 996, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 998, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1000, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1002, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1004, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 996, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 998, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1000, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1002, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
       {x = 1004, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
   }
   
   local container_id_new = 1428
   local container_id_broken = 1427
   local actionid = 43600
   local storage_amount_of_opened_boxes = 1001
   for i = 1, #boxes do
   
   
       if getThingFromPos(boxes[i]).itemid == container_id_broken then
           doTransformItem(getThingFromPos(boxes[i]).uid, container_id_new)
           doSetItemActionId(getThingFromPos(boxes[i]).uid, actionid)   
       end
   end
return TRUE
end

local config = {
questFromPos = {x=991,y=995,z=5, stackpos=253},
questToPos = {x=1009,y=1011,z=5, stackpos=253}}

function endDungeon()
for _, pid in ipairs(getPlayersOnline()) do
        if isInArea(getPlayerPosition(pid), config.questFromPos, config.questTopos) then
            doTeleportThing(pid, {x=1000,y=1000,z=7,stackpos=1}, false)
        end
    end
end

function onKill(cid, target)
local config = {
    ["rat"] = {storage = 1050},
    ["cave rat"] = {storage = 1050}
}

local monster = config[getCreatureName(target):lower()]


    if(isPlayer(target)) or not monster then 
    return TRUE
    end
       
    if getGlobalStorageValue(monster.storage) >= 0 then  
     setGlobalStorageValue(monster.storage, getGlobalStorageValue(monster.storage) +1)
    end
   
    if getGlobalStorageValue(2050) == 0 and getGlobalStorageValue(1050) == 10 then
    setGlobalStorageValue(1050,-1)
    setGlobalStorageValue(2050,-1)
    resetQuest()
    endDungeon()
end
return TRUE
end

bump, with my last script please.. maybe with for _, spec in ipairs(getSpectators ....... works?

Bump...

Bump
 
Last edited by a moderator:
Back
Top