Lembrando que é um globalevent agora...
local function getWinnerCastle(cid)
local THRONE_POS = {x = 561, y = 446, z = 5}
local DUR = 10 -- in minutes
CastleWalls()
local player = getTopCreature(THRONE_POS).uid
if getGlobalStorageValue(STORAGE_EVENT) < 0 then
return true
end
if (isPlayer(player)) then
if (getPlayerStorageValue(player, STORAGE_PLAYER) > 0) then
pid = getPlayerGUID(cid)
setHouseOwner(6258, pid)
doPlayerAddPremiumDays(player, 7)
for _, cid in ipairs(getPlayersOnline()) do
setPlayerStorageValue(cid, STORAGE_PLAYER, 0)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
doBroadcastMessage(getCreatureName(player) .. " ganhou o evento.", 25)
doTeleportThing(player, {x = 531, y = 460, z = 7})
doCreateItem(391, 1, {x = 500, y = 500, z = 7})
end
else
doBroadcastMessage("Ningúem ganhou o evento.", 27)
for _, pid in ipairs(getPlayersOnline()) do
setPlayerStorageValue(pid, STORAGE_PLAYER, 0)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
end
end
setGlobalStorageValue(STORAGE_EVENT, 0)
return db.executeQuery("DELETE FROM `player_storage` WHERE `key` = " .. STORAGE_PLAYER)
end
local function OpenEvent()
local STORAGE_EVENT = 83902
local STORAGE_PLAYER = 73289
for _, tid in ipairs(getPlayersOnline()) do
setPlayerStorageValue(tid, STORAGE_PLAYER, 1)
end
setGlobalStorageValue(STORAGE_EVENT, 1)
doBroadcastMessage("O Evento castle foi aberto.", 25)
end
local function CastleWalls()
local pedra = getTileItemById({ x = 539, y = 474, z = 7}, 1285)
local escada = getTileItemById({ x = 539, y = 474, z = 7}, 3687)
if pedra.uid > 0 then
return doRemoveItem(pedra.uid)
else
return doCreateItem(1285, 1, { x = 500, y = 500, z = 7})
end
if escada.uid > 0 then
return doRemoveItem(escada.uid)
else
return doCreateItem(3687, 1, {x = 500, y = 500, z = 7})
end
end
function onThink(cid, interval, lastexecution)
local times = {
["12:00"] = {date="Saturday"},
["14:00"] = {date="Sunday"}
}
if getGlobalStorageValue(19234, 1) then return false end
if times[hours] ~= false and os.date("%A") == times[hours].date then
doCreateItem(3687, 1, {x = 500, y = 500, z = 7})
OpenEvent()
CastleWalls()
addEvent(getWinnerCastle, DUR * 60 * 1000)
addEvent(function () setGlobalStorageValue(19234, 1) end, os.clock()+600)
end
return true
end