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

function doRandomTeleport(cid, xi, yi, zi, xf, yf, zf)

Status
Not open for further replies.

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
:(this aint working neither
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
 
Sorry i dont know but first of all dont recomend use random teleport...
mayby use random places example : are 20 random places and thoose places will by random... becouse that script i think should by not stable...

but just im thinking so...


/apsivaflines
 
actually I am using the script that you say;

Lua:
local portals = {
        {x=1035, y=1033, z=7},
        {x=1036, y=1033, z=7},
        {x=1037, y=1033, z=7},
        {x=1038, y=1033, z=7},
        {x=1039, y=1033, z=7},
        {x=1040, y=1033, z=7},
        {x=1041, y=1033, z=7},
        {x=1042, y=1033, z=7},
        {x=1043, y=1033, z=7},
        {x=1044, y=1033, z=7}
}

for i = 1, #specs do
rand = math.random(1, #portals)
doTeleportThing(specs[i], portals[rand])
end.etc

but I hate it, I need random teleport in an area, I know it is possible and stable with all these new LUA codes
 
actually I am using the script that you say;

Lua:
local portals = {
        {x=1035, y=1033, z=7},
        {x=1036, y=1033, z=7},
        {x=1037, y=1033, z=7},
        {x=1038, y=1033, z=7},
        {x=1039, y=1033, z=7},
        {x=1040, y=1033, z=7},
        {x=1041, y=1033, z=7},
        {x=1042, y=1033, z=7},
        {x=1043, y=1033, z=7},
        {x=1044, y=1033, z=7}
}

for i = 1, #specs do
rand = math.random(1, #portals)
doTeleportThing(specs[i], portals[rand])
end.etc

but I hate it, I need random teleport in an area, I know it is possible and stable with all these new LUA codes
Code:
for i = 1, #specs do
	doTeleportThing(specs[i], {x=math.random(1035, 1044), y=1033, z=7})
end
?
It won't check if the tile is walkable though.
 
Status
Not open for further replies.
Back
Top