Hello, i have problem in making script. What i want is to teleport player to random place in area, but it can't be protection zone and must be walkable because my script is teleport players into water or walls...
Lua:
function onSay(player, words, param)
if not player:getTile():hasFlag(TILESTATE_PROTECTIONZONE) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use this command inside Protection Zone!")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local from = {x=1075,y=1061}
local to = {x=1221,y=1186}
local setZ = 7
local setX = math.random(from.x,to.x)
local setY = math.random(from.y,to.y)
local position = {x = setX,y = setY,z = setZ}
player:teleportTo(position)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end