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

MoveEvent [TFS 1.1] Teleporter spot(configurable price and storage)

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,694
Location
Poland
improved version of this: https://otland.net/threads/tfs-1-1-...ablo-3-teleport-great-for-rpg-servers.230015/

stepping on spot unlocks it
configurable price
id 3169, set uid and add it to table later to create spot

creaturescripts.xml
Code:
  <event type="modalwindow" name="tp_pad" script="tp_pad.lua"/>
   <event type="login" name="tp_pad_register" script="tp_pad.lua"/>

tp_pad.lua creaturescript
Code:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
   if modalWindowId == 1860 then
     if not tp_pads[choiceId + 8300] then
       return true
     end
   
     local npos = Item(choiceId + 8300):getPosition()
     if buttonId == 1 then
       if tp_pads[choiceId + 8300].price ~= nil then
         if not doPlayerRemoveMoney(player, tp_pads[choiceId + 8300].price) then
           doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You don't have enough money.")
           return true
         end
       end
       
       player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
       player:teleportTo(npos)
       player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
       return true
     end
   end
   return true
end

function onLogin(player)
   player:registerEvent("tp_pad")
   return true
end

movements.xml
Code:
<movevent event="StepIn" itemid="3169" script="tp_pad.lua"/>

tp_pad.lua movement
Code:
tp_pads = {
   [8301] = {price = 300, name = "Spot 1", storage = 99586},
   [8302] = {price = 300, name = "Spot 2", storage = 99587},
   [8303] = {price = 0, name = "Spot 3", storage = 99588},
   [8304] = {price = 300, name = "Spot 4", storage = 99589},
   [8305] = {price = 300, name = "Spot 5", storage = 99590}
}

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
 
You may register it on any itemid, I didn't limit that in my script.
 
Last edited:
You may register it on any itemid, I didn't limit that in my script.
Damn, I know I'm freakin brainless but. Is it correct to do as I wrote before? Is that where I'm suppose to change the ID of the item I am using?

And
[8301] = {price = 300, name = "Thais", storage = 99586},
[8302] = {price = 300, name = "Venore", storage = 99587}
bolded number is same as action id on the item?
 
Last edited:
Damn, I know I'm freakin brainless but. Is it correct to do as I wrote before? Is that where I'm suppose to change the ID of the item I am using?

And
[8301] = {price = 300, name = "Thais", storage = 99586},
[8302] = {price = 300, name = "Venore", storage = 99587}
bolded number is same as action id on the item?
stepping on spot unlocks it
configurable price
id 3169, set uid and add it to table later to create spot
also:

if not tp_pads[item.uid] then return true end
 
[uniqueid] = {price = cost (if 0 or not specified, it will be free), name = "text in list", storage = (optional) storage to unlock spot, if none, it will be unlocked by default}
 
before you report a bug, range of choice ids is 1-255
it's calculated this way: choiceid = uniqueid - 8300
it means you may use uid 8301-8555, unless you do some changes to the script to calculate it different way

Using uids is intended here - you don't need to set positions in script (uid is used to get destination)
 
stepping on spot unlocks it
configurable price
id 3169, set uid and add it to table later to create spot
also:

if not tp_pads[item.uid] then return true end
I tried using another item to step on, does it have to be a floor-item? And when I use 3169 it looks like this:
f4JtA2T.png

And says I have to:
fTFA2u6.png
 
Alright, so this is how it looks right now. In the map editor.
But well yea, when I stepped on it now my Tibia client crashed, without any Errors in Console.
vCCWsgG.png

And movements.xml
Code:
<movevent event="StepIn" itemid="18001" script="tp_pad.lua"/>
When I restarted Tibia it seemed to work though.
KR55udX.jpg

Okey, the options shows up but when I "select" on "Thais" nothing happends. And the FIRST time i step on one of the tps tibia crashes. Error from that:
GqBhcar.png
 
Last edited:
function doPlayerRemoveMoney(cid, money) local p = Player(cid) return p ~= nil and p:removeMoney(money) or false end
 
Back
Top