darkmu
Well-Known Member
What is happening is that if they pull the switch and people leave the waiting room it just crashes the server, does anyone know a solution for this?
will that solve the problem?
Lua:
local t = {
Position(299, 219, 10), -- Alavanca
}
local function backLever()
local tile = t[1]:getTile()
local alavanca = tile:getItemById(9826)
if alavanca then
alavanca:transform(9825)
end
end
local function startArena(creatures)
for _, pid in ipairs(creatures) do
pid:sendTextMessage(MESSAGE_INFO_DESCR, 'Você foi teleportado para a arena, sobreviva até o fim para receber a sua recompensa !!!')
_CHAMPARENA_LH.addPlayer(pid)
if Game.getStorageValue(_CHAMPARENA_LH.global_storage) == -1 then
Game.setStorageValue(_CHAMPARENA_LH.global_aux, -1)
_CHAMPARENA_LH.open()
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 9825 then
local count, creatures = 0, Game.getSpectators(Position(305, 218, 10), false, false, 10, 10, 10, 10)
if creatures ~= nil then
for _, pid in ipairs(creatures) do
if isPlayer(pid) then
count = count + 1
end
end
end
if count >= 1 then
for _, pid in ipairs(creatures) do
pid:sendTextMessage(MESSAGE_INFO_DESCR, 'Aguarde 2 minutos para serem teleportados para Arena !!!')
end
addEvent(startArena, 2 * 6 * 1000, creatures)
addEvent(backLever, 3 * 6 * 1000)
item:transform(item.itemid == 9826 and 9825 or 9826)
end
end
return true
end
will that solve the problem?
Lua:
local function startArena(creatures)
if creatures then
for _, pid in ipairs(creatures) do
pid:sendTextMessage(MESSAGE_INFO_DESCR, 'Você foi teleportado para a arena, sobreviva até o fim para receber a sua recompensa !!!')
_CHAMPARENA_LH.addPlayer(pid)
if Game.getStorageValue(_CHAMPARENA_LH.global_storage) == -1 then
Game.setStorageValue(_CHAMPARENA_LH.global_aux, -1)
_CHAMPARENA_LH.open()
end
end
end
end