Lua:
local config = {
playerPositions = {
Position(736, 929, 8),
Position(737, 929, 8),
Position(738, 929, 8)
},
newPositions = {
Position(748, 933, 8),
Position(750, 933, 8),
Position(732, 929, 8)
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1946 then
local storePlayers, playerTile = {}
for i = 1, #config.playerPositions do
playerTile = Tile(config.playerPositions[i]):getTopCreature()
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
return true
end
storePlayers[#storePlayers + 1] = playerTile
end
local players
for i = 1, #storePlayers do
local randomPosition = config.newPositions[math.random(#config.newPositions)]
players = storePlayers[i]
config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
players:teleportTo(randomPosition)
players:setDirection(EAST)
end
end
item:transform(item.itemid == 1946 and 1945 or 1946)
return true
end
How to make everyone teleported to 1 random place?
Because now it happens that 2 players teleport to the same place.
Last edited: