Hello Guys, good night.
I back studing some lua again, after 5 years, and the things have change a bit.
I try make a script, still works, but i have a error in console.
For exemple, when 4 players stay in x,y,z they are tp to x,y,z.
Script-
<globalevent name="Enter Arena" interval="2000" script="enterarena.lua"/>
local playerPosition = {
{x = 24999, y = 24985, z = 7},
{x = 25000, y = 24984, z = 7},
{x = 25001, y = 24985, z = 7},
{x = 25000, y = 24986, z = 7}
}
local newPosition = {
{x = 25000, y = 25000, z = 7},
{x = 25000, y = 25000, z = 7},
{x = 25000, y = 25000, z = 7},
{x = 25000, y = 25000, z = 7}
}
function onThink(interval, lastExecution)
local players = Game.getPlayers()
if #players == 0 then -- 0 players online, no need to execute the script
return true
end
local players = {}
for _, pos in ipairs(playerPosition) do
local player = Tile(pos):getTopCreature()
if player == nil or not player:isPlayer() then
return false
end
players[#players+1] = player
end
for i, player in ipairs(players) do
Position(playerPosition):sendMagicEffect(11)
player:teleportTo(newPosition, false)
player:setDirection(SOUTH)
end
return true
end
I have this error, but the script works well, someone know what a hell is that?
[Error - GlobalEvents::think] Failed to execute event: Enter Arena
I back studing some lua again, after 5 years, and the things have change a bit.
I try make a script, still works, but i have a error in console.
For exemple, when 4 players stay in x,y,z they are tp to x,y,z.
Script-
<globalevent name="Enter Arena" interval="2000" script="enterarena.lua"/>
local playerPosition = {
{x = 24999, y = 24985, z = 7},
{x = 25000, y = 24984, z = 7},
{x = 25001, y = 24985, z = 7},
{x = 25000, y = 24986, z = 7}
}
local newPosition = {
{x = 25000, y = 25000, z = 7},
{x = 25000, y = 25000, z = 7},
{x = 25000, y = 25000, z = 7},
{x = 25000, y = 25000, z = 7}
}
function onThink(interval, lastExecution)
local players = Game.getPlayers()
if #players == 0 then -- 0 players online, no need to execute the script
return true
end
local players = {}
for _, pos in ipairs(playerPosition) do
local player = Tile(pos):getTopCreature()
if player == nil or not player:isPlayer() then
return false
end
players[#players+1] = player
end
for i, player in ipairs(players) do
Position(playerPosition):sendMagicEffect(11)
player:teleportTo(newPosition, false)
player:setDirection(SOUTH)
end
return true
end
I have this error, but the script works well, someone know what a hell is that?
[Error - GlobalEvents::think] Failed to execute event: Enter Arena