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

Support Teleport Item

hyz

Member
Joined
Oct 30, 2008
Messages
39
Reaction score
16
I would like help to make a script.
Explaining: The player can only use the item in sqms
x = 2424 y = 435 z = 7
x = 2425 y = 435 z = 7
x = 2426 y = 435 z = 7

After using the item the player will be teleported to random location
x = 2214 y = 635 z = 7
x = 1980 y = 540 z = 7
x = 2426 y = 600 z = 7

After using the item it disappears.

The Player will only be able to use the item again after 30 seconds.
 
I would like help to make a script.
Explaining: The player can only use the item in sqms
x = 2424 y = 435 z = 7
x = 2425 y = 435 z = 7
x = 2426 y = 435 z = 7

After using the item the player will be teleported to random location
x = 2214 y = 635 z = 7
x = 1980 y = 540 z = 7
x = 2426 y = 600 z = 7

After using the item it disappears.

The Player will only be able to use the item again after 30 seconds.
try this?
Lua:
local exstorage = 45001
local extimer = 30

local accepted_positions = {
  {x = 1000, y = 1000, z = 7},
  {x = 1001, y = 1001, z = 7},
  {x = 1002, y = 1002, z = 7}
}

local random_positions = {
  {x = 1000, y = 1000, z = 7},
  {x = 1001, y = 1001, z = 7},
  {x = 1002, y = 1002, z = 7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if exhaustion.check(cid, exstorage) then
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    return true
  end
  for i = 1, #accepted_positions do
    if accepted_positions[i].z == fromPosition.z then
      if accepted_positions[i].y == fromPosition.y then
        if accepted_positions[i].x == fromPosition.x then
          exhaustion.set(cid, exstorage, extimer)
          doTeleportThing(cid, random_positions[math.random(#random_positions)])
          break
        end
      end
    end
  end
  return true
end
 
try this?
Lua:
local exstorage = 45001
local extimer = 30

local accepted_positions = {
  {x = 1000, y = 1000, z = 7},
  {x = 1001, y = 1001, z = 7},
  {x = 1002, y = 1002, z = 7}
}

local random_positions = {
  {x = 1000, y = 1000, z = 7},
  {x = 1001, y = 1001, z = 7},
  {x = 1002, y = 1002, z = 7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if exhaustion.check(cid, exstorage) then
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    return true
  end
  for i = 1, #accepted_positions do
    if accepted_positions[i].z == fromPosition.z then
      if accepted_positions[i].y == fromPosition.y then
        if accepted_positions[i].x == fromPosition.x then
          exhaustion.set(cid, exstorage, extimer)
          doTeleportThing(cid, random_positions[math.random(#random_positions)])
          break
        end
      end
    end
  end
  return true
end
What if those positions are non walkable?
 
What if those positions are non walkable?
Then the character wouldn't be able to stand on that position, or teleport to that position.
(well.. maybe teleport, but why would you set a position that characters are not supposed to go?)
Can shorten it to be like that too i guess
Lua:
if accepted_positions[i] == fromPosition then
in 0.x server's we can't :/
At least it's never worked when I've tried previously.
 
Then the character wouldn't be able to stand on that position, or teleport to that position.
(well.. maybe teleport, but why would you set a position that characters are not supposed to go?)

in 0.x server's we can't :/
At least it's never worked when I've tried previously.
Lua:
local accepted_positions = {
  {x = 1000, y = 1000, z = 7},
  {x = 1001, y = 1001, z = 7},
  {x = 1002, y = 1002, z = 7}
}

for _, position in pairs(accepted_positions) do
    for property, value in pairs(position) do
        if fromPosition[property] == value then
        end
    end
end
Bad example but maybe you can use an increment to validate if the position is correct.
 
Back
Top