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

Teleport from same position.

Suxex

Member
Joined
Aug 13, 2007
Messages
391
Reaction score
5
Location
Halland - Getinge
Is it possible to teleport more then one player from same position at the same time? The area is PZ, that's why they can be on the same tile ;)

Thanks in advance.
 
He means two people on top of each other in Depot or something, and teleport them both. He would have to make a script for it.
 
You can try this:

Lua:
local k = getThingFromPos(position).uid
if k ~= 0 then
	doRelocate(position, toPosition)
end
Should work just fine.
 
It didn't work quite right, I need to have a whole area checked and if players stand on eachother on several tiles.
Your script just teleport players from 1 specific tilem right?
 
Lua:
local t = {
	fromPos = {x = 100, y = 100, z = 7},
	toPos = {x = 100, y = 100, z = 7},
	teleportTo = {x = 100, y = 100, z = 7}
	}
function blablabla()
	for _, pid in ipairs(getPlayersOnline()) do
		if isInRange(getCreaturePosition(pid), t.fromPos, t.toPos) then
			if pid ~= nil then
				repeat 
					doTeleportThing(pid, t.teleportTo)
				until pid == nil
			end
		end
	end
return true
end
 
Last edited:
The teleport part of my script looks like this.

Lua:
function Teleport() 
	local t = {
		fromPos = {x = 33253, y = 32353, z = 9},
		toPos = {x = 33269, y = 32367, z = 9},
		teleportTo = {x = 33261, y = 32358, z = 11}
	}
		for _, pid in ipairs(getPlayersOnline()) do
			if isInRange(getCreaturePosition(pid), t.fromPos, t.toPos) then
				repeat 
					doTeleportThing(pid, t.teleportTo)
					setPlayerStorageValue(pid, 335500, 1)
				until pid == nil
			end
		end
end

But the server crashes and no errors appear in log file when I teleports.
 
Lua:
function getPlayersInRange(position, radiusx, radiusy)
	local creaturesList = {}
	for x = -radiusx, radiusx do
		for y = -radiusy, radiusy do
			if not (x == 0 and y == 0) then
				local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
				if creature.type == 1 then
					table.insert(creaturesList, creature.uid)
				end
			end
		end
	end

	local creature = getTopCreature(position)
	if creature.type == 1 then
		if not(table.find(creaturesList, creature.uid)) then
			table.insert(creaturesList, creature.uid)
		end
	end
    return creaturesList
end

local t, n, storage = {
	{x=2368, y=1575, z=7},
	{x=2368, y=1576, z=7},
	{x=2368, y=1577, z=7},
	{x=2368, y=1578, z=7},
}, {
	{x=2344, y=1531, z=7},
	{x=2345, y=1531, z=7},
	{x=2346, y=1531, z=7},
	{x=2347, y=1531, z=7},
}, {
	placed = 10001,
	max = 10002,
	radius = 10003
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, item.itemid - 1)
	end

	local v = getPlayersInRange({x=864, y=1335, z=7}, 34, 30)
	if #v > 1 then
		return doPlayerSendCancel(cid, "Please wait for the current match to end.")
	end

	local players = {}
	for i = 1, #t do
		local v = getTopCreature(t[i]).uid 
		players[i] = isPlayer(v) and v or nil
	end

	if #players < 2 then
		return doPlayerSendCancel(cid, "You need at least 2 players to enter.")
	end
	
	local first = players[1] and 1 or players[2] and 2 or players[3] and 3 or players[4] and 4
	for i = 1, 4 do
		if players[i] then
			setPlayerStorageValue(players[i], storage.placed, 0)
			setPlayerStorageValue(players[i], storage.max, 1)
			setPlayerStorageValue(players[i], storage.radius, 1)
			doSendMagicEffect(t[i], CONST_ME_TELEPORT)
			doTeleportThing(players[i], n[i])
			doSendMagicEffect(n[i], CONST_ME_TELEPORT)
		end
	end

	doTransformItem(item.uid, item.itemid + 1)
	return true
end

its able for 4 players
 
Back
Top