Yes broMaybe explain more for people who don't know soulwar quest.
So there are 8 boats where you want if a player is on any of them then he gets kicked/teleported out after 2 minutes?
local positions = {
Position(33830, 30981, 8)
}
local config = {
playerPositions = {
Position(33910, 31001, 9), -- 1
},
newPositions = {
Position(33910, 31001, 8), -- 1
},
}
local config2 = {
playerPositions = {
Position(33910, 31001, 9), -- 1
},
newPositions = {
Position(33910, 31001, 8), -- 1
},
}
local config3 = {
playerPositions = {
Position(33911, 31001, 9), -- 1
},
newPositions = {
Position(33911, 31001, 8), -- 1
},
}
local config4 = {
playerPositions = {
Position(33911, 31001, 8), -- 1
},
newPositions = {
Position(33911, 31001, 9), -- 1
},
}
function onThink(interval, lastExecution)
local item
for i = 1, #positions do
item = Tile(positions[i]):getThing(1)
if item and isInArray({1945, 1946}, item.itemid) then
item:transform(item.itemid == 1945 and 1946 or 1945)
for _, player in ipairs(Game.getPlayers()) do
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
return true
end
player:teleportTo(config.newPositions[i])
end
else
for i = 1, #config2.playerPositions do
playerTile = Tile(config2.playerPositions[i]):getTopCreature()
if not playerTile or not playerTile:isPlayer() then
return true
end
player:teleportTo(config2.newPositions[i])
end
end
end
end
end
return true
end
teleportToPosition
from the table and start addEvent
to kick players in the range fromPosition
toPosition
to the kickPos
for each actionId on the table after 2 minutes passed.local soulWarBoats = Action()
local soulWarPositions = {
-- [actionId]
[1000] = {
teleportToPosition = {x = 500, y = 500, z = 7},
fromPosition = {x = 1000, y = 1000, z = 7},
toPosition = {x = 2000, y = 2000, z = 7},
kickPos = {x = 3000, y = 3000, z = 7}
},
[2000] = {
teleportToPosition = {x = 500, y = 500, z = 7},
fromPosition = {x = 1000, y = 1000, z = 7},
toPosition = {x = 2000, y = 2000, z = 7},
kickPos = {x = 3000, y = 3000, z = 7}
}
}
function soulWarBoats.onUse(player, item, fromPos, target, toPos, isHotkey)
local soulWarBoats = soulWarPositions[item:getActionId()]
player:teleportTo(soulWarBoats.teleportToPosition)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
for v, k in pairs(soulWarPositions) do
addEvent(
function(playerId)
local boatPlayer = Player(playerId)
if not boatPlayer or not boatPlayer:isPlayer() then
return nil
end
if boatPlayer then
local boatPlayerPos = boatPlayer:getPosition()
local leftTopCorner = k.fromPosition
local rightBottomCorner = k.fromPosition
if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then
boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
boatPlayer:teleportTo(k.kickPos)
end
end
end,
2 * 60 * 1000,
player:getId()
)
end
return true
end
for v, k in pairs(soulWarPositions) do
soulWarBoats:aid(v)
end
soulWarBoats:register()
No bro, the lever was just a reference I had for the TP to happen automatically. It works like this... Every 2 minutes the boat rises and falls with the flood, and with that the player is teleported to the same position upstairs and the same thing downstairs. In fact there is no lever in this system, I just found a reference to try to make the system, because I don't understand much about LUA =/Something like this? Using the lever will teleport player toteleportToPosition
from the table and startaddEvent
to kick players in the rangefromPosition
toPosition
to thekickPos
for each actionId on the table after 2 minutes passed.
LUA:local soulWarBoats = Action() local soulWarPositions = { -- [actionId] [1000] = { teleportToPosition = {x = 500, y = 500, z = 7}, fromPosition = {x = 1000, y = 1000, z = 7}, toPosition = {x = 2000, y = 2000, z = 7}, kickPos = {x = 3000, y = 3000, z = 7} }, [2000] = { teleportToPosition = {x = 500, y = 500, z = 7}, fromPosition = {x = 1000, y = 1000, z = 7}, toPosition = {x = 2000, y = 2000, z = 7}, kickPos = {x = 3000, y = 3000, z = 7} } } function soulWarBoats.onUse(player, item, fromPos, target, toPos, isHotkey) local soulWarBoats = soulWarPositions[item:getActionId()] player:teleportTo(soulWarBoats.teleportToPosition) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) for v, k in pairs(soulWarPositions) do addEvent( function(playerId) local boatPlayer = Player(playerId) if not boatPlayer or not boatPlayer:isPlayer() then return nil end if boatPlayer then local boatPlayerPos = boatPlayer:getPosition() local leftTopCorner = k.fromPosition local rightBottomCorner = k.fromPosition if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) boatPlayer:teleportTo(k.kickPos) end end end, 2 * 60 * 1000, player:getId() ) end return true end for v, k in pairs(soulWarPositions) do soulWarBoats:aid(v) end soulWarBoats:register()
onStepIn
and add actionIds to the boat tiles.local soulWarBoats = MoveEvent()
soulWarBoats:type("stepin")
local soulWarPositions = {
-- [actionId]
[1000] = {
teleportToPosition = {x = 500, y = 500, z = 7},
fromPos = {x = 1000, y = 1000, z = 7},
toPosition = {x = 2000, y = 2000, z = 7},
kickPos = {x = 3000, y = 3000, z = 7}
},
[2000] = {
teleportToPosition = {x = 500, y = 500, z = 7},
fromPos = {x = 1000, y = 1000, z = 7},
toPosition = {x = 2000, y = 2000, z = 7},
kickPos = {x = 3000, y = 3000, z = 7}
}
}
function soulWarBoats.onStepIn(creature, item, position, fromPosition)
local soulWarBoats = soulWarPositions[item:getActionId()]
if not creature:isPlayer() then
return true
end
creature:teleportTo(soulWarBoats.teleportToPosition)
creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
for v, k in pairs(soulWarPositions) do
addEvent(
function(playerId)
local boatPlayer = Player(playerId)
if not boatPlayer or not boatPlayer:isPlayer() then
return nil
end
if boatPlayer then
local boatPlayerPos = boatPlayer:getPosition()
local leftTopCorner = k.fromPos
local rightBottomCorner = k.fromPos
if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then
boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
boatPlayer:teleportTo(k.kickPos)
end
end
end,
2 * 60 * 1000,
creature:getId()
)
end
return true
end
for v, k in pairs(soulWarPositions) do
soulWarBoats:aid(v)
end
soulWarBoats:register()
It doesn't work synchronized with the map script. I believe it has to be onThink, just like I was trying to doYou can use the same script above but change toonStepIn
and add actionIds to the boat tiles.
LUA:local soulWarBoats = MoveEvent() soulWarBoats:type("stepin") local soulWarPositions = { -- [actionId] [1000] = { teleportToPosition = {x = 500, y = 500, z = 7}, fromPos = {x = 1000, y = 1000, z = 7}, toPosition = {x = 2000, y = 2000, z = 7}, kickPos = {x = 3000, y = 3000, z = 7} }, [2000] = { teleportToPosition = {x = 500, y = 500, z = 7}, fromPos = {x = 1000, y = 1000, z = 7}, toPosition = {x = 2000, y = 2000, z = 7}, kickPos = {x = 3000, y = 3000, z = 7} } } function soulWarBoats.onStepIn(creature, item, position, fromPosition) local soulWarBoats = soulWarPositions[item:getActionId()] if not creature:isPlayer() then return true end creature:teleportTo(soulWarBoats.teleportToPosition) creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT) for v, k in pairs(soulWarPositions) do addEvent( function(playerId) local boatPlayer = Player(playerId) if not boatPlayer or not boatPlayer:isPlayer() then return nil end if boatPlayer then local boatPlayerPos = boatPlayer:getPosition() local leftTopCorner = k.fromPos local rightBottomCorner = k.fromPos if boatPlayerPos:isInRange(leftTopCorner, rightBottomCorner) then boatPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) boatPlayer:teleportTo(k.kickPos) end end end, 2 * 60 * 1000, creature:getId() ) end return true end for v, k in pairs(soulWarPositions) do soulWarBoats:aid(v) end soulWarBoats:register()