silveralol
Advanced OT User
- Joined
- Mar 16, 2010
- Messages
- 1,480
- Solutions
- 9
- Reaction score
- 211
Hello, I'm trying using a table as parameter to use in another function ...
then I want to pass it to another function ...
the function is just to check the ID of the players...
so, in the case...
player A was insert in playersTable using the .uid, so in the function only player A should be teleported somewhere
but if has a player B not insert in playersTable, he will got teleported out of the room
I try use this function from orts as model
So folks, how I can pass tables as parameters and it work how I expect?
Code:
above the function ofc ...
local playerTable = {}
for i = 1, #playerPos do
local playerTile = Tile(playerPos[i]):getTopCreature()
if playerTile and playerTile:isPlayer() then
table.insert(playerTable, playerTile.uid)
playerTile:teleportTo(some room)
end
end
Code:
addEvent(checkPlayers, 1 * 60 * 1000, playerTable) -- how pas it ?
Code:
local function checkPlayers(playerTable)
local spectators = Game.getSpectators(Position(), false, false, 5, 5, 5, 5)
for i = 1, #spectators do
local spectator = spectators[i]
if playerTable ~= nil then
if isInArray(playerTable, spectator.uid) then
spectator:teleportTo(somewhere)
end
end
end
end
player A was insert in playersTable using the .uid, so in the function only player A should be teleported somewhere
but if has a player B not insert in playersTable, he will got teleported out of the room
I try use this function from orts as model
Code:
local function clearBossRoom(playerId, bossId,
centerPosition,
rangeX, rangeY, exitPosition)
local spectators, spectator = Game.getSpectators(centerPosition, false, false,
rangeX,
rangeX, rangeY, rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() and spectator.uid == playerId then
spectator:teleportTo(exitPosition)
exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if spectator:isMonster() and spectator.uid == bossId then
spectator:remove()
end
end
end