• 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 waypoints exausted

jel

Member
Joined
Mar 22, 2014
Messages
302
Reaction score
12
hello, could someone be exhausted in this script for the player to be able to teleport in the same place only after 2 min

Lua:
local WINDOW_ID = 4203
local BUTTON_ACCEPT = 0
local BUTTON_CLOSE = 1

local WAYPOINTS_STORAGE = 41875
local WAYPOINTS = {
  [1] = {
    name = "Ghostlands",
    position = Position(32189, 31809, 6)
  },
  [2] = {
    name = "Plains of Havoc",
    position = Position(32715, 32328, 6)
  },
  [3] = {
    name = "Ankrahmun Desert",
    position = Position(33207, 32675, 6)
  },
  [4] = {
    name = "Edron Nort",
    position = Position(33159, 31657, 6)
  },
  [5] = {
    name = "Roshamuul Nort",
    position = Position(33631, 32385, 6)
  },
  [6] = {
    name = "Issavi Centre",
    position = Position(33896, 31511, 6)
  },
  [7] = {
    name = "Svargrond",
    position = Position(32296, 31152, 6)
  },
  [8] = {
    name = "Liberty Bay Nort",
    position = Position(32306, 32740, 6)
  },
  [9] = {
    name = "Port Hope Nort",
    position = Position(32643, 32679, 6)
  },
  [10] = {
    name = "Yalahar Nort",
    position = Position(32775, 31074, 6)
  },
  [11] = {
    name = "Oramond",
    position = Position(33677, 31950, 6)
  },
  [12] = {
    name = "Zao Step",
    position = Position(33153, 31246, 6)
  }
}

function onStepIn(player, item, position, fromPosition)
  if player:isPlayer() and fromPosition:getDistance(position) == 1 then
    
    for i = 1, #WAYPOINTS do
      local waypoint = WAYPOINTS[i]
      if position == waypoint.position and player:getStorageValue(WAYPOINTS_STORAGE + i) ~= 1 then
        player:setStorageValue(WAYPOINTS_STORAGE + i, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "New waypoint unlocked!\n-- " .. waypoint.name .. " --")
        return true
      end
    end

    local empty = true
    for i = 1, #WAYPOINTS do
      local waypoint = WAYPOINTS[i]
      if position == waypoint.position and player:getStorageValue(WAYPOINTS_STORAGE + i) == 1 then
        empty = false
        break
      end
    end

    if not empty then
      player:registerEvent("WaypointsModal")
      
      local title = "Teletransport"
      local message = "Choose your destination."
      
      local window = ModalWindow(WINDOW_ID, title, message)

      window:addButton(BUTTON_ACCEPT, "Teleport")
      window:addButton(BUTTON_CLOSE, "Close")

      for i = 1, #WAYPOINTS do
        local waypoint = WAYPOINTS[i]
        if player:getStorageValue(WAYPOINTS_STORAGE + i) == 1 then
          window:addChoice(i, waypoint.name)
        end
      end

      window:setDefaultEnterButton(BUTTON_ACCEPT)
      window:setDefaultEscapeButton(BUTTON_CLOSE)

      window:sendToPlayer(player)
    end
  end
    return true
end

function onWaypointsModal(player, modalWindowId, buttonId, choiceId) 
  player:unregisterEvent("WaypointsModal")

  if modalWindowId == WINDOW_ID then
      if buttonId == BUTTON_ACCEPT then
        if player:getStorageValue(WAYPOINTS_STORAGE + choiceId) == 1 then
          player:teleportTo(WAYPOINTS[choiceId].position)
          WAYPOINTS[choiceId].position:sendMagicEffect(CONST_ME_ENERGYAREA)
        end
      end
  end
end
 
Solution
required: Player.setExhaustion, Player.getExhaustion [TFS 1.0] (https://otland.net/threads/player-setexhaustion-player-getexhaustion-tfs-1-0.224233/)

tested and working

Lua:
local WINDOW_ID = 4203
local BUTTON_ACCEPT = 0
local BUTTON_CLOSE = 1

local WAYPOINTS_STORAGE = 41875
local WAYPOINTS = {
  [1] = {
    name = "Ghostlands",
    storage = 5000,
    position = Position(32189, 31809, 6)
  },
  [2] = {
    name = "Plains of Havoc",
    storage = 5001,
    position = Position(32715, 32328, 6)
  },
  [3] = {
    name = "Ankrahmun Desert",
    storage = 5002,
    position = Position(33207, 32675, 6)
  },
  [4] = {
    name = "Edron Nort",
    storage = 5003,
    position = Position(33159, 31657, 6)
  },
  [5] = {
    name =...
required: Player.setExhaustion, Player.getExhaustion [TFS 1.0] (https://otland.net/threads/player-setexhaustion-player-getexhaustion-tfs-1-0.224233/)

tested and working

Lua:
local WINDOW_ID = 4203
local BUTTON_ACCEPT = 0
local BUTTON_CLOSE = 1

local WAYPOINTS_STORAGE = 41875
local WAYPOINTS = {
  [1] = {
    name = "Ghostlands",
    storage = 5000,
    position = Position(32189, 31809, 6)
  },
  [2] = {
    name = "Plains of Havoc",
    storage = 5001,
    position = Position(32715, 32328, 6)
  },
  [3] = {
    name = "Ankrahmun Desert",
    storage = 5002,
    position = Position(33207, 32675, 6)
  },
  [4] = {
    name = "Edron Nort",
    storage = 5003,
    position = Position(33159, 31657, 6)
  },
  [5] = {
    name = "Roshamuul Nort",
    storage = 5004,
    position = Position(33631, 32385, 6)
  },
  [6] = {
    name = "Issavi Centre",
    storage = 5005,
    position = Position(33896, 31511, 6)
  },
  [7] = {
    name = "Svargrond",
    storage = 5006,
    position = Position(32296, 31152, 6)
  },
  [8] = {
    name = "Liberty Bay Nort",
    storage = 5007,
    position = Position(32306, 32740, 6)
  },
  [9] = {
    name = "Port Hope Nort",
    storage = 5008,
    position = Position(32643, 32679, 6)
  },
  [10] = {
    name = "Yalahar Nort",
    storage = 5009,
    position = Position(32775, 31074, 6)
  },
  [11] = {
    name = "Oramond",
    storage = 5010,
    position = Position(33677, 31950, 6)
  },
  [12] = {
    name = "Zao Step",
    storage = 5011,
    position = Position(33153, 31246, 6)
  }
}

function onStepIn(player, item, position, fromPosition)
  if player:isPlayer() and fromPosition:getDistance(position) == 1 then
 
    for i = 1, #WAYPOINTS do
      local waypoint = WAYPOINTS[i]
      if position == waypoint.position and player:getStorageValue(WAYPOINTS_STORAGE + i) ~= 1 then
        player:setStorageValue(WAYPOINTS_STORAGE + i, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "New waypoint unlocked!\n-- " .. waypoint.name .. " --")
        return true
      end
    end

    local empty = true
    for i = 1, #WAYPOINTS do
      local waypoint = WAYPOINTS[i]
      if position == waypoint.position and player:getStorageValue(WAYPOINTS_STORAGE + i) == 1 then
        empty = false
        break
      end
    end

    if not empty then
      player:registerEvent("WaypointsModal")
   
      local title = "Teletransport"
      local message = "Choose your destination."
   
      local window = ModalWindow(WINDOW_ID, title, message)

      window:addButton(BUTTON_ACCEPT, "Teleport")
      window:addButton(BUTTON_CLOSE, "Close")

      for i = 1, #WAYPOINTS do
        local waypoint = WAYPOINTS[i]
        if player:getStorageValue(WAYPOINTS_STORAGE + i) == 1 then
          window:addChoice(i, waypoint.name)
        end
      end

      window:setDefaultEnterButton(BUTTON_ACCEPT)
      window:setDefaultEscapeButton(BUTTON_CLOSE)

      window:sendToPlayer(player)
    end
  end
    return true
end

function onWaypointsModal(player, modalWindowId, buttonId, choiceId)
    if player:getExhaustion(WAYPOINTS[choiceId].storage) > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are exhausted for "..player:getExhaustion(WAYPOINTS[choiceId].storage).." secs")
    end
    player:unregisterEvent("WaypointsModal")

  if modalWindowId == WINDOW_ID then
      if buttonId == BUTTON_ACCEPT then
        if player:getStorageValue(WAYPOINTS_STORAGE + choiceId) == 1 then
          player:teleportTo(WAYPOINTS[choiceId].position)
          player:setExhaustion(WAYPOINTS[choiceId].storage, 120)
          WAYPOINTS[choiceId].position:sendMagicEffect(CONST_ME_ENERGYAREA)
        end
      end
  end
end
 
Solution
Back
Top