• 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.2 portals from TFS 1.1 bug in console

Verrine

Member
Joined
Mar 2, 2016
Messages
117
Reaction score
7
Hi i posted here https://otland.net/threads/tfs-1-1-teleporter-spot-configurable-price-and-storage.230096/page-2 but i doesnt get any respond from anyone. Ive copied it to TFS 1.2 it looks like working script but when i step in unique id nothing happens in Tibia but in console there is 1 error like there:
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/tp_pad.lua:onStepIn
data/movements/scripts/tp_pad.lua:33: attempt to index field '?' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/tp_pad.lua:33: in function <data/movements/scripts/tp_pad.lua:7>

the code in LUA:
Code:
tp_pads = {
   [8301] = {price = 1, name = "Thais", storage = 99586},
   [8302] = {price = 1, name = "PoH", storage = 99587}

}

function onStepIn(player, item, position, fromPosition)
   if not tp_pads[item.uid] then return true end

   if not isInRange(position, {x = fromPosition.x - 1, y = fromPosition.y - 1, z = fromPosition.z}, {x = fromPosition.x + 1, y = fromPosition.y + 1, z = fromPosition.z}) then
     -- player got there from another pad
     return true
   end

   if not player:isPlayer() then
     return true
   end
  
   if tp_pads[item.uid].storage then
     if player:getStorageValue(tp_pads[item.uid].storage) < 1 then
       player:setStorageValue(tp_pads[item.uid].storage, 1)
       player:say("Spot unlocked.", TALKTYPE_ORANGE_1, true, player, player:getPosition())
     end
   end
  
   if player:isPzLocked() then
     player:teleportTo(fromPosition)
     player:say("The pad is not responding.", TALKTYPE_ORANGE_1, true, player, player:getPosition())
   else
     local padWindow = ModalWindow(1860, "Teleport", "Select destination:")
     for i = 8301, 8305 do
       if i ~= item.uid then
         if tp_pads[i].price then
           if tp_pads[i].storage then
             if player:getStorageValue(tp_pads[i].storage) > 0 then
               padWindow:addChoice(i - 8300, tp_pads[i].name .. (tp_pads[i].price > 0 and " [" .. tp_pads[i].price .. " gold]" or ""))
             end
           else
             padWindow:addChoice(i - 8300, tp_pads[i].name .. (tp_pads[i].price > 0 and " [" .. tp_pads[i].price .. " gold]" or ""))
           end
         else
           if tp_pads[i].storage then
             if player:getStorageValue(tp_pads[i].storage) > 0 then
               padWindow:addChoice(i - 8300, tp_pads[i].name)
             end
           else
             padWindow:addChoice(i - 8300, tp_pads[i].name)
           end
         end
       end
     end
     padWindow:addButton(1, "Select")
     padWindow:addButton(2, "Cancel")
     padWindow:setDefaultEnterButton(1)
     padWindow:setDefaultEscapeButton(2)
     padWindow:sendToPlayer(player)
   end
   return true
end

i dont know whats going on im not pro in TFS scripting but i dont see any errors in lua scrip, how can i repair it?
 
Hi i posted here https://otland.net/threads/tfs-1-1-teleporter-spot-configurable-price-and-storage.230096/page-2 but i doesnt get any respond from anyone. Ive copied it to TFS 1.2 it looks like working script but when i step in unique id nothing happens in Tibia but in console there is 1 error like there:
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/tp_pad.lua:onStepIn
data/movements/scripts/tp_pad.lua:33: attempt to index field '?' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/tp_pad.lua:33: in function <data/movements/scripts/tp_pad.lua:7>

the code in LUA:
Code:
tp_pads = {
   [8301] = {price = 1, name = "Thais", storage = 99586},
   [8302] = {price = 1, name = "PoH", storage = 99587}

}

function onStepIn(player, item, position, fromPosition)
   if not tp_pads[item.uid] then return true end

   if not isInRange(position, {x = fromPosition.x - 1, y = fromPosition.y - 1, z = fromPosition.z}, {x = fromPosition.x + 1, y = fromPosition.y + 1, z = fromPosition.z}) then
     -- player got there from another pad
     return true
   end

   if not player:isPlayer() then
     return true
   end

   if tp_pads[item.uid].storage then
     if player:getStorageValue(tp_pads[item.uid].storage) < 1 then
       player:setStorageValue(tp_pads[item.uid].storage, 1)
       player:say("Spot unlocked.", TALKTYPE_ORANGE_1, true, player, player:getPosition())
     end
   end

   if player:isPzLocked() then
     player:teleportTo(fromPosition)
     player:say("The pad is not responding.", TALKTYPE_ORANGE_1, true, player, player:getPosition())
   else
     local padWindow = ModalWindow(1860, "Teleport", "Select destination:")
     for i = 8301, 8305 do
       if i ~= item.uid then
         if tp_pads[i].price then
           if tp_pads[i].storage then
             if player:getStorageValue(tp_pads[i].storage) > 0 then
               padWindow:addChoice(i - 8300, tp_pads[i].name .. (tp_pads[i].price > 0 and " [" .. tp_pads[i].price .. " gold]" or ""))
             end
           else
             padWindow:addChoice(i - 8300, tp_pads[i].name .. (tp_pads[i].price > 0 and " [" .. tp_pads[i].price .. " gold]" or ""))
           end
         else
           if tp_pads[i].storage then
             if player:getStorageValue(tp_pads[i].storage) > 0 then
               padWindow:addChoice(i - 8300, tp_pads[i].name)
             end
           else
             padWindow:addChoice(i - 8300, tp_pads[i].name)
           end
         end
       end
     end
     padWindow:addButton(1, "Select")
     padWindow:addButton(2, "Cancel")
     padWindow:setDefaultEnterButton(1)
     padWindow:setDefaultEscapeButton(2)
     padWindow:sendToPlayer(player)
   end
   return true
end

i dont know whats going on im not pro in TFS scripting but i dont see any errors in lua scrip, how can i repair it?
Line 32 change "if i ~= item.uid then"
To:
Code:
if i ~= item.uid and tp_pads[i] then
 
You are my master LOL why that was bugged so much? this one line i dont understand

1 more question, can it be done for only premium users?
 
Last edited:
Back
Top