this aint working neither
I want to tp to a random pos between an area(from x1 to x2, etc)
I want to tp to a random pos between an area(from x1 to x2, etc)
Lua:
function isPositionFree(pos)
local thing = getTopCreature(pos)
if isCreature(thing.uid) == FALSE then
pos.stackpos = 0
thing = getThingfromPos(pos)
if thing.uid > 0 then
while hasProperty(thing.uid, CONST_PROP_BLOCKINGANDNOTMOVEABLE) == FALSE do
pos.stackpos = pos.stackpos + 1
thing = getThingfromPos(pos)
if thing.uid == FALSE then
return TRUE
end
end
end
end
return FALSE
end
function doRandomTeleport(cid, xi, yi, zi, xf, yf, zf)
xx = math.random(xi,xf)
yy = math.random(yi,yf)
zz = math.random(zi,zf)
target = {x = xx,y = yy,z = zz}
if isPositionFree(target) == true then
doTeleportThing(cid, target)
end
return true
end