Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local THRONE_POS = {x = 1, y = 2, z = 3}
- local STORAGE_EVENT = 83902
- local STORAGE_PLAYER = 73289
- local REWARDS = {{2160, 10}, {2159, 30}}
- local DUR = 30 -- in minutes
- function OpenEvent()
- for _, tid in ipairs(getPlayersOnline()) do
- setPlayerStorageValue(tid, STORAGE_PLAYER, 1)
- end
- setGlobalStorageValue(STORAGE_EVENT, 1)
- doBroadcastMessage("O Evento castle foi aberto.", 25)
- end
- function getWinnerCastle()
- 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
- for _, T in pairs(REWARDS) do
- doPlayerAddItem(player, T[1], T[2])
- end
- for _, cid in ipairs(getPlayersOnline()) do
- setPlayerStorageValue(cid, STORAGE_PLAYER, 0)
- doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
- end
- doBroadcastMessage(getCreatureName(player) .. " ganhou o evento.", 25)
- end
- else
- doBroadcastMessage("Ningúem ganhou o evento.", 27)
- for _, pid in ipairs(getPlayersOnline()) do
- doPlayerAddItem(pid, 2160, 100)
- 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
- function CastleWalls()
- local walls = {
- {ID, POS},
- {ID, POS},
- }
- for _, K in pairs(walls) do
- local wall = getTileItemById(K[2], K[1])
- if (wall.uid > 0) then
- doRemoveItem(wall.uid)
- else
- doCreateItem(K[1], 1, K[2])
- end
- end
- end
- function onSay(cid, words, param, channel)
- if ((param == "abrir") and (getGlobalStorageValue(STORAGE_EVENT) == 1)) then
- doPlayerSendTextMessage(cid, 27, "O evento já esta aberto.") return true
- elseif ((param == "fechar") and (getGlobalStorageValue(STORAGE_EVENT) == 1)) then
- getWinnerCastle()
- CastleWalls() return true
- end
- OpenEvent()
- CastleWalls()
- addEvent(getWinnerCastle(), DUR * 60 * 1000)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment