Postado Agosto 5, 2020 4 anos Este é um post popular. [SafeZone 1.x] Hellou galera, a um tempo atrás tinha postado um safezone que eu e o @luanluciano93 tinhamos feito e por algumas questões resolvi apagar o tópico. Hoje venho postá-lo novamente porém mais otimizado e com maior número de configurações. Qualquer bug que houver durante o decorrer do evento só me avisar nesse tópico que irei fixar (SOMENTE NESSE TÓPICO, NÃO ME PROCUREM NO DISCORD NEM VIA PM) Na pasta lib, crie um arquivo chamado safezone.lua --[[ Evento SafeZone escrito por LuanLuciano93 e Movie (Movie#4361) Otimizado por Movie Disponibilizado para o TibiaKing e não autorizo outras reproduções Mantenha os créditos <3 --]] SAFEZONE = { teleportTimeClose = 5, eventTimeTotal = 30, positionTeleportOpen = Position(1003, 1217, 7), -- Posição que o portal irá abrir positionEnterEvent = Position(1545, 957, 7), -- Para onde os players irão storage = 12149, -- Não mexa actionId = 6412, -- ActionID que irá no portal ao ser criado, tem que ser o mesmo do movements protectionTileId = {9562, 9563, 9564, 9565}, -- ID dos pisos que serão criados levelMin = 150, minPlayers = 5, maxPlayers = 50, reward = {9020, 5}, -- ID do Item, Quantidade players = {}, days = { ["Sunday"] = {"20:00"}, ["Monday"] = {"20:00"}, ["Tuesday"] = {"20:00"}, ["Wednesday"] = {"20:00"}, ["Thursday"] = {"20:00"}, ["Friday"] = {"20:00"}, ["Saturday"] = {"20:00"}, }, messages = { prefix = "[SafeZone] ", messageStart = "O evento irá começar agora com %d participantes! Boa sorte!", messageNoStart = "O evento não foi iniciado por falta de participantes!", messageTime = "O evento foi finalizado por ultrapassar o limite de tempo!", messageOpen = "O evento foi aberto, você tem %d minutos para entrar no portal do evento que se encontra no templo!", messageWait = "O teleporte para o evento está aberto, você tem %d minuto(s) para entrar!", messageFinish = "O evento foi finalizado e o ganhador foi o %s! Parabéns!", messageWinner = "Você ganhou %d %s como premiação pelo primeiro lugar!", }, lifeColor = { [1] = 94, -- red [2] = 77, -- orange [3] = 79 -- yellow }, positionEvent = {firstTile = {x = 1538, y = 951, z = 7}, tilesX = 15, tilesY = 11} -- No final do tópico ensino a configurar } function SAFEZONE:teleportCheck() local tile = Tile(SAFEZONE.positionTeleportOpen) if tile then local item = tile:getItemById(1387) if item then item:remove() local totalPlayers = SAFEZONE:totalPlayers() if totalPlayers >= SAFEZONE.minPlayers then Game.broadcastMessage(SAFEZONE.messages.prefix .. SAFEZONE.messages.messageStart:format(totalPlayers), MESSAGE_STATUS_WARNING) SAFEZONE:createProtectionTiles() addEvent(function() if totalPlayers > 0 then Game.broadcastMessage(SAFEZONE.messages.prefix .. SAFEZONE.messages.messageTime, MESSAGE_STATUS_WARNING) SAFEZONE:removePlayers() end end, SAFEZONE.eventTimeTotal * 60 * 1000) else Game.broadcastMessage(SAFEZONE.messages.prefix .. SAFEZONE.messages.messageNoStart, MESSAGE_STATUS_WARNING) SAFEZONE:removePlayers() end else Game.broadcastMessage(SAFEZONE.messages.prefix .. SAFEZONE.messages.messageOpen:format(SAFEZONE.teleportTimeClose), MESSAGE_STATUS_WARNING) addEvent(Game.broadcastMessage, (SAFEZONE.teleportTimeClose - 3) * 60 * 1000, SAFEZONE.messages.prefix .. (SAFEZONE.messages.messageWait):format(SAFEZONE.teleportTimeClose - 2)) addEvent(Game.broadcastMessage, (SAFEZONE.teleportTimeClose - 1) * 60 * 1000, SAFEZONE.messages.prefix .. (SAFEZONE.messages.messageWait):format(SAFEZONE.teleportTimeClose - 4)) local teleport = Game.createItem(1387, 1, SAFEZONE.positionTeleportOpen) if teleport then teleport:setActionId(SAFEZONE.actionId) end addEvent(function() SAFEZONE:teleportCheck() end, SAFEZONE.teleportTimeClose * 60000) end end end function SAFEZONE:removePlayers() for a in pairs(SAFEZONE.players) do local player = Player(a) player:setStorageValue(SAFEZONE.storage, 0) player:teleportTo(player:getTown():getTemplePosition()) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) end end function SAFEZONE:insertPlayer(playerId) SAFEZONE.players[playerId] = {} end function SAFEZONE:removePlayer(playerId) SAFEZONE.players[playerId] = nil end function SAFEZONE:totalPlayers() local x = 0 for a in pairs(SAFEZONE.players) do x = x + 1 end return x end function SAFEZONE:totalProtectionTile() local totalPlayers = SAFEZONE:totalPlayers() if totalPlayers >= 10 then return totalPlayers - 3 else return totalPlayers - 1 end end function SAFEZONE:createProtectionTiles() local totalPlayers = SAFEZONE:totalPlayers() if SAFEZONE:totalPlayers() == 1 then for a in pairs(SAFEZONE.players) do local player = Player(a) if player:getStorageValue(SAFEZONE.storage) > 0 then player:setStorageValue(SAFEZONE.storage, 0) SAFEZONE.players[a] = nil player:teleportTo(player:getTown():getTemplePosition()) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) local itemType = ItemType(SAFEZONE.reward[1]) if itemType:getId() ~= 0 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, SAFEZONE.messages.prefix .. SAFEZONE.messages.messageWinner:format(SAFEZONE.reward[2],itemType:getName())) player:addItem(itemType:getId(), SAFEZONE.reward[2]) end Game.broadcastMessage(SAFEZONE.messages.prefix .. SAFEZONE.messages.messageFinish:format(player:getName()), MESSAGE_STATUS_WARNING) end end elseif totalPlayers >= SAFEZONE.minPlayers then local createTiles, totalTiles = 0, SAFEZONE:totalProtectionTile() local tileX = SAFEZONE.positionEvent.firstTile.x local tileY = SAFEZONE.positionEvent.firstTile.y local tileZ = SAFEZONE.positionEvent.firstTile.z local tilesX = SAFEZONE.positionEvent.tilesX local tilesY = SAFEZONE.positionEvent.tilesY local protectionTileId = SAFEZONE.protectionTileId while createTiles < totalTiles do local randomX = math.random(tileX, tileX + tilesX) local randomY = math.random(tileY, tileY + tilesY) local newPosition = Position({x = randomX, y = randomY, z = tileZ}) local tile = Tile(newPosition) if tile then local item1 = tile:getItemById(protectionTileId[1]) local item2 = tile:getItemById(protectionTileId[2]) local item3 = tile:getItemById(protectionTileId[3]) local item4 = tile:getItemById(protectionTileId[4]) if not item1 and not item2 and not item3 and not item4 then local randomTile = math.random(protectionTileId[1], protectionTileId[4]) local tileProtection = Game.createItem(randomTile, 1, newPosition) if tileProtection then tileProtection:getPosition():sendMagicEffect(CONST_ME_ENERGYHIT) addEvent(function() SAFEZONE:deleteProtectionTiles(newPosition, randomTile) end, 5000) createTiles = createTiles + 1 end end end end addEvent(function() SAFEZONE:effectArea(SAFEZONE.positionEvent.firstTile, SAFEZONE.positionEvent.tilesX, SAFEZONE.positionEvent.tilesY) end, 5000) addEvent(function() SAFEZONE:checkPlayersinProtectionTiles() end, 4000) addEvent(function() SAFEZONE:createProtectionTiles() end, 6000) end end function SAFEZONE:deleteProtectionTiles(position, tileId) local tile = Tile(position) if tile then local item = tile:getItemById(tileId) if item then item:getPosition():sendMagicEffect(CONST_ME_POFF) item:remove() end end end function SAFEZONE:checkPlayersinProtectionTiles() local protectionTileId = SAFEZONE.protectionTileId for a in pairs(SAFEZONE.players) do local player = Player(a) if player:getStorageValue(SAFEZONE.storage) > 0 then local tile = Tile(player:getPosition()) if tile then local item1 = tile:getItemById(protectionTileId[1]) local item2 = tile:getItemById(protectionTileId[2]) local item3 = tile:getItemById(protectionTileId[3]) local item4 = tile:getItemById(protectionTileId[4]) if not item1 and not item2 and not item3 and not item4 then if player:getStorageValue(SAFEZONE.storage) > 1 then player:setStorageValue(SAFEZONE.storage, player:getStorageValue(SAFEZONE.storage) - 1) local lifes = player:getStorageValue(SAFEZONE.storage) player:setStorageValue(SAFEZONE.storage, 0) player:getPosition():sendMagicEffect(CONST_ME_FIREAREA) SAFEZONE.players[player:getId()] = nil local outfit = player:getSex() == 0 and 136 or 128 if lifes == 1 then local lifeColor = SAFEZONE.lifeColor[1] player:setOutfit({lookType = outfit, lookHead = lifeColor, lookBody = lifeColor, lookLegs = lifeColor, lookFeet = lifeColor}) elseif lifes == 2 then local lifeColor = SAFEZONE.lifeColor[2] player:setOutfit({lookType = outfit, lookHead = lifeColor, lookBody = lifeColor, lookLegs = lifeColor, lookFeet = lifeColor}) end player:setStorageValue(SAFEZONE.storage, lifes) else player:setStorageValue(SAFEZONE.storage, 0) player:getPosition():sendMagicEffect(CONST_ME_FIREAREA) player:teleportTo(player:getTown():getTemplePosition()) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) end end end end end end function SAFEZONE:effectArea(firstTile, tilesX, tilesY) local fromPosition = firstTile local toPositionX = fromPosition.x + tilesX local toPositionY = fromPosition.y + tilesY for x = fromPosition.x, toPositionX do for y = fromPosition.y, toPositionY do local position = Position({x = x, y = y, z = fromPosition.z}) if position then position:sendMagicEffect(CONST_ME_SMALLPLANTS) end end end end Não esqueça de registrar essa lib no lib.lua Agora na pasta movements/scripts crie um arquivo chamado safezone.lua --[[ Evento SafeZone escrito por LuanLuciano93 e Movie (Movie#4361) Otimizado por Movie Disponibilizado para o TibiaKing e não autorizo outras reproduções Mantenha os créditos <3 --]] function onStepIn(creature, item, position, fromPosition) local player = creature:getPlayer() if not player then return true end if player:getGroup():getAccess() then player:teleportTo(SAFEZONE.positionEnterEvent) return true end if player:getLevel() < SAFEZONE.levelMin then player:sendCancelMessage(SAFEZONE.messages.prefix .."Você precisa ser level " .. SAFEZONE.levelMin .. "ou maior para entrar no evento.") player:teleportTo(fromPosition, true) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end if player:getItemCount(2165) >= 1 then player:sendCancelMessage(SAFEZONE.messages.prefix .."Você não pode entrar com um stealth ring no evento.") player:teleportTo(fromPosition, true) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end local ring = player:getSlotItem(CONST_SLOT_RING) if ring then if ring:getId() == 2202 then player:sendCancelMessage(SAFEZONE.messages.prefix .." Você não pode entrar no evento com um stealth ring.") player:teleportTo(fromPosition, true) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end end for a in pairs(SAFEZONE.players) do target = Player(a) if player:getIp() == target:getIp() then player:sendCancelMessage(SAFEZONE.messages.prefix .. "Você já possui um outro player dentro do evento.") player:teleportTo(fromPosition, true) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end end if SAFEZONE:totalPlayers() >= SAFEZONE.maxPlayers then player:sendCancelMessage(SAFEZONE.messages.prefix .. "O evento já atingiu o número máximo de participantes.") player:teleportTo(fromPosition, true) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end local outfit = player:getSex() == 0 and 136 or 128 local treeLifeColor = SAFEZONE.lifeColor[3] player:setOutfit({lookType = outfit, lookHead = treeLifeColor, lookBody = treeLifeColor, lookLegs = treeLifeColor, lookFeet = treeLifeColor}) player:sendTextMessage(MESSAGE_INFO_DESCR, SAFEZONE.messages.prefix .."Você entrou no evento. Boa sorte!") player:teleportTo(SAFEZONE.positionEnterEvent) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) player:setStorageValue(SAFEZONE.storage, 3) SAFEZONE:insertPlayer(player:getId()) return true end <movevent event="StepIn" actionid="6412" script="safezone.lua" /> Agora vá na pasta globalevents/scripts e crie o arquivo safezone.lua function onThink(interval) if SAFEZONE.days[os.date("%A")] then local hrs = tostring(os.date("%X")):sub(1, 5) if isInArray(SAFEZONE.days[os.date("%A")], hrs) then SAFEZONE:teleportCheck() end end return true end <globalevent name="SafeZone" interval="60000" script="safezone.lua" /> No quadrado azul marinho você configura a posição do firstTile = {x = x, y = y, z = z} Em verde, você conta quantos quadrados existem e coloque em tilesX = quantidade Em vermelho, você conta quantos quadrados existem e coloque em tilesY = quantidade De resto, as outras configurações estão bem explícitas. Créditos 30% Movie 69% @luanluciano93 1% @WooX (pela divisória rs) Editado Agosto 7, 2020 4 anos por Movie (veja o histórico de edições) Baiak Thunder New TFS Downgrade [TFS 1.5 - 8.60] Gesior Ferobra Downgrade Evento Monster Hunt [TFS 1.X] Evento SafeZone [TFS 1.X] Online Bonus System [TFS 1.X] Dodge & Critical [TFS 1.X] Nova moeda, funcionando com NPCs [TFS 1.X] Square System [TFS 1.X] Loot Channel [TFS 1.X] Gerenciador de Quests [All TFS] NPCs comprando vial/flasks por storage [TFS 1.X] AntiBot [TFS 1.X] Como compilar TFS 0.X
Postado Agosto 5, 2020 4 anos Sistema top mano, ta de parabéns. Spoiler 43 minutos atrás, Movie disse: 1% @WooX (pela divisória rs) Nós somos aquilo que fazemos repetidamente. Excelência, não é um modo de agir, mas um hábito. Aristóteles
Postado Setembro 3, 2020 4 anos Spoiler [3:10:55.556] [Error - GlobalEvent Interface] [3:10:55.556] data/globalevents/scripts/safezone.lua:onThink [3:10:55.556] Description: [3:10:55.556] data/lib/safezone.lua:49: attempt to call global 'Tile' (a nil value) [3:10:55.556] stack traceback: [3:10:55.556] data/lib/safezone.lua:49: in function 'teleportCheck' [3:10:55.557] data/globalevents/scripts/safezone.lua:5: in function <data/globalevents/scripts/safezone.lua:1> [3:10:55.557] [Error - GlobalEvents::think] Couldn't execute event: SafeZone Aqui deu isso
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.