silveralol
Advanced OT User
- Joined
- Mar 16, 2010
- Messages
- 1,480
- Solutions
- 9
- Reaction score
- 211
hello folks, I'm working on a quest that have one lever...
is 15 SQM's
divided like this:
then I need teleport each team to different rooms
each team must to be 3 players.... exemple:
if the team 1 have TWO players the third player must be the first of team 2
I do some code but it don't work :/
I got error in:
local position = Rooms[roomIndex].position
and ofc I don't check if the creature in the sqm is player, I'm testing with monsters
I can't see what is wrong in this line, please someone give me a light
thank you
edit: with this code the first creatures go to different rooms,
player 1 is teleported to room 1....
the problem seems with how I handle with each team and the index, but I can't solve
is 15 SQM's
divided like this:
then I need teleport each team to different rooms
each team must to be 3 players.... exemple:
if the team 1 have TWO players the third player must be the first of team 2
I do some code but it don't work :/
Code:
local Rooms = {
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)}
}
local PlayerPositions = {
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)},
{position = Position(x, y, z)}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local roomIndex, storePlayers = 1, {}
for i = 1, #PlayerPositions do
local position = PlayerPositions[i].position
local playerTile = Tile(PlayerPositions[i].position):getTopCreature()
if playerTile then
storePlayers[#storePlayers + 1] = playerTile
for a = 1, 3 do
local player = storePlayers[a]
if player then
local position = Rooms[roomIndex].position
player:teleportTo(position)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
print('player Name: ' ..player:getName())
end
if a == 3 then
storePlayers = {}
roomIndex = roomIndex + 1
end
end
end
end
return true
end
local position = Rooms[roomIndex].position
and ofc I don't check if the creature in the sqm is player, I'm testing with monsters
I can't see what is wrong in this line, please someone give me a light
thank you
edit: with this code the first creatures go to different rooms,
player 1 is teleported to room 1....
the problem seems with how I handle with each team and the index, but I can't solve
Last edited: