Tudo que Movie postou
-
[10.98] Real War - OT 100% War
Agora eu sei resolver grande parte desses erros aí, seu corno... Porém é um ótimo servidor para se trabalhar e faltam poucas coisas para se terminar ele.
-
Gesior Ferobra - Open Source
Utilize Linux para rodar seu OT e seu site. Até então, não sei a versão que pode ser utilizada em Windows. Em breve irei disponibilizar um novo site melhor, mas sem data prevista.
-
Evento Monster Hunt TFS 1.X
Itens aleatórios como prêmio, você diz?
-
Evento Monster Hunt TFS 1.X
Evento Monster Hunt Durante uma hora, o player que mais matar um monstro específico ganha o evento. Na pasta lib, crie um arquivo chamado monsterHunt.lua com isso dentro MONSTER_HUNT = { list = {"Demon", "Rotworm", "Cyclops"}, days = { ["Sunday"] = {"13:55"}, ["Monday"] = {"13:55"}, ["Tuesday"] = {"13:55"}, ["Wednesday"] = {"13:55"}, ["Thursday"] = {"13:55"}, ["Friday"] = {"13:55"}, ["Saturday"] = {"13:55"}, }, messages = { prefix = "[Monster Hunt] ", warnInit = "O evento irá começar em %d minuto%s. Seu objetivo será matar a maior quantidade de monstros escolhidos pelo sistema.", init = "O monstro escolhido pelo sistema foi %s. Você tem 1 hora para matar a maior quantidade desse monstro.", warnEnd = "Faltam %d minuto%s para acabar o evento. Se apressem!", final = "O jogador %s foi o ganhador do evento! Parabéns.", noWinner = "Não houve ganhadores no evento.", reward = "Você recebeu o seu prêmio no mailbox!", kill = "Você já matou {%d} %s do evento.", }, rewards = { {id = 2160, count = 100}, }, storages = { monster = 891641, player = 891642, }, players = {}, } function MONSTER_HUNT:initEvent() Game.setStorageValue(MONSTER_HUNT.storages.monster, 0) Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(5, "s")) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(3, "s")) end, 2 * 60 * 1000) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(1, "")) end, 4 * 60 * 1000) addEvent(function() local rand = math.random(#MONSTER_HUNT.list) Game.setStorageValue(MONSTER_HUNT.storages.monster, rand) Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.init:format(MONSTER_HUNT.list[rand])) end, 5 * 60 * 1000) return true end function MONSTER_HUNT:endEvent() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(5, "s")) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(3, "s")) end, 2 * 60 * 1000) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(1, "")) end, 4 * 60 * 1000) addEvent(function() if #MONSTER_HUNT.players == nil then Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.noWinner) return end table.sort(MONSTER_HUNT.players, function(a,b) return a[2] > b[2] end) local player = Player(MONSTER_HUNT.players[1][1]) if player then Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName())) player:setStorageValue(MONSTER_HUNT.storages.player, -1) for c, d in ipairs(MONSTER_HUNT.rewards) do local item = Game.createItem(d.id, d.count) player:addItemEx(item) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.reward) player:getPosition():sendMagicEffect(30) end --[[ Função exclusiva (ignore) else local player = Player(MONSTER_HUNT.players[1][1], true) if not player then return false end Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName())) player:setStorageValue(MONSTER_HUNT.storages.player, -1) for c, d in ipairs(MONSTER_HUNT.rewards) do local item = Game.createItem(d.id, d.count) player:getInbox():addItemEx(item, INDEX_WHEREEVER, FLAG_NOLIMIT) end player:delete() --]] end for a, b in pairs(MONSTER_HUNT.players) do local player = Player(b[1]) if player then player:setStorageValue(MONSTER_HUNT.storages.player, 0) MONSTER_HUNT.players[a] = nil --[[ Função exclusiva (ignore) else player = Player(b[1], true) player:setStorageValue(MONSTER_HUNT.storages.player, 0) MONSTER_HUNT.players[a] = nil player:delete() --]] end end Game.setStorageValue(MONSTER_HUNT.storages.monster, -1) end, 5 * 60 * 1000) return true end Não esqueça de registrar essa lib no lib.lua Agora em globalevents, crie um arquivo na pasta scripts com isso dentro function onThink(interval) if MONSTER_HUNT.days[os.date("%A")] then local hrs = tostring(os.date("%X")):sub(1, 5) if isInArray(MONSTER_HUNT.days[os.date("%A")], hrs) then MONSTER_HUNT:initEvent() end end return true end function onTime(interval) MONSTER_HUNT:endEvent() return true end Não esqueça de adicionar a tag no globalevents <globalevent name="MonsterHunt" interval="60000" script="custom/events/monsterHunt.lua" /> <globalevent name="MonsterHuntEnd" time="14:55" script="custom/events/monsterHunt.lua" /> Agora em creaturescripts, crie um arquivo na pasta scripts com isso dentro function onKill(player, target) if Game.getStorageValue(MONSTER_HUNT.storages.monster) == nil then return true end if not player or not target then return true end if player:getStorageValue(MONSTER_HUNT.storages.player) == -1 then player:setStorageValue(MONSTER_HUNT.storages.player, 0) end if target:isMonster() and target:getName():lower() == (MONSTER_HUNT.list[Game.getStorageValue(MONSTER_HUNT.storages.monster)]):lower() then player:setStorageValue(MONSTER_HUNT.storages.player, player:getStorageValue(MONSTER_HUNT.storages.player) + 1) player:sendTextMessage(MESSAGE_STATUS_BLUE_LIGHT, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName())) table.insert(MONSTER_HUNT.players, {player:getId(), player:getStorageValue(MONSTER_HUNT.storages.player)}) end return true end Com a tag no creaturescripts <event type="kill" name="MonsterHunt" script="custom/monsterHunt.lua" /> Não esqueça de registrar o evento no login.lua player:registerEvent("MonsterHunt") Bom aproveito. Créditos: 100% meu
-
Square System TFS 1.X
Square System Esse sistema irá possibilitar você colocar uma square em determinado player. Em luascript.cpp, acima de registerMethod("Player", "isPlayer", LuaScriptInterface::luaPlayerIsPlayer); coloque isso registerMethod("Player", "sendCreatureSquare", LuaScriptInterface::luaSendCreatureSquare); Agora, acima de int LuaScriptInterface::luaPlayerCreate(lua_State* L) Coloque isso int LuaScriptInterface::luaSendCreatureSquare(lua_State* L) { // player:sendCreatureSquare(creature, color) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } Creature* creature = getUserdata<Creature>(L, 2); if (!creature) { lua_pushnil(L); return 1; } uint32_t color = getNumber<uint32_t>(L, 3, 0); player->sendCreatureSquare(creature, static_cast <SquareColor_t>(color)); lua_pushboolean(L, true); return 1; } Agora em luascript.h, antes de static int luaPlayerIsPlayer(lua_State* L); adicione isso static int luaSendCreatureSquare(lua_State* L); Agora para utilizar use player:sendCreatureSquare(creature, color) Boa criatividade. Créditos: 100% meu
-
Loot Channel TFS 1.X
Loot Channel para TFS 1.X Liberando mais alguns conteúdos para vocês. Dessa vez o loot channel para tfs 1.x. Crie um arquivo chamado loot.lua na pasta chatchannels/scripts contendo isso local STORAGEVALUE_LOOT = 8914 function onSpeak(player, type, message) return false end function onJoin(player) player:setStorageValue(STORAGEVALUE_LOOT, 1) return true end function onLeave(player) player:setStorageValue(STORAGEVALUE_LOOT, 0) return true end Agora em chatchannels.xml adicione a tag <channel id="11" name="Loot" script="loot.lua" /> Em events/scripts, abra o arquivo monster.lua e você provavelmente irá encontra-lo assim function Monster:onDropLoot(corpse) if configManager.getNumber(configKeys.RATE_LOOT) == 0 then return end local player = Player(corpse:getCorpseOwner()) local mType = self:getType() if not player or player:getStamina() > 840 then local monsterLoot = mType:getLoot() for i = 1, #monsterLoot do local item = corpse:createLootItem(monsterLoot[i]) if not item then print('[Warning] DropLoot:', 'Could not add loot item to corpse.') end end if player then local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else player:sendTextMessage(MESSAGE_INFO_DESCR, text) end end else local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else player:sendTextMessage(MESSAGE_INFO_DESCR, text) end end end Altere para esse local STORAGEVALUE_LOOT = 8914 function Monster:onDropLoot(corpse) if configManager.getNumber(configKeys.RATE_LOOT) == 0 then return end local player = Player(corpse:getCorpseOwner()) local mType = self:getType() if not player or player:getStamina() > 840 then local monsterLoot = mType:getLoot() for i = 1, #monsterLoot do local item = corpse:createLootItem(monsterLoot[i]) if not item then print('[Warning] DropLoot:', 'Could not add loot item to corpse.') end end if player then local text = ("Loot de %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then sendChannelMessage(11, TALKTYPE_CHANNEL_O, text) else player:sendTextMessage(MESSAGE_INFO_DESCR, text) end end end else local text = ("Loot de %s: nada (devivo a baixa stamina)"):format(mType:getNameDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then sendChannelMessage(11, TALKTYPE_CHANNEL_O, text) else player:sendTextMessage(MESSAGE_INFO_DESCR, text) end end end end Pronto, adicionado o Loot Channel! Créditos: 100% meu
-
Alavanca Issavi
A melhor forma seria via getSpectators.
-
Zombie Event [DIFERENCIADO]
Ando muito ocupado, as vezes que entro no fórum ou no discord da academia de codding estou pelo celular. De qualquer forma, irei disponibilizar isso gratuitamente, portanto faço no meu tempo. Espero que consiga trazer logo pro 1.x, daí não vou ter que terminar de passar
-
Gerenciador de Quests [TFS 0.X e TFS 1.X]
No 1.x funciona sem as libs. Para usar com 0.x precisa das libs.
-
Gerenciador de Quests [TFS 0.X e TFS 1.X]
Fala pessoal, como vocês estão? Na academia de codding um usuário pediu ajuda para montar um "gerenciador" de quests, para que todas ficassem no mesmo arquivo sem ficar com aquele "spam" de quests nas actions. Esse script foi feito para a TFS 1.X mas, usando a lib do @Mathias Kenfi, você consegue utilizar para TFS 0.X também. O link para as libs: https://github.com/kenfi2/KenfiLib Na pasta actions/scripts crie um arquivo chamado quests.lua config = { quests = { [7172] = { -- ActionID que será colocado no baú name = "dos Crystal Coins", -- Nome da quest rewards = { {id = 2160, count = 100}, -- Prêmio: ID - Count }, level = { active = true, -- Level minimo para pegar? min = 150, -- Se true, qual o minimo }, storage = { active = true, -- Player poderá pegar somente uma vez? key = 91143, -- Apenas uma key por quest }, effectWin = 30, -- Efeito que vai aparecer quando fizer a quest }, [7171] = { -- ActionID que será colocado no baú name = "dos Coins", -- Nome da quest rewards = { {id = 2160, count = 100}, -- Prêmio: ID - Count {id = 2152, count = 100}, -- Prêmio: ID - Count }, level = { active = true, -- Level minimo para pegar? min = 150, -- Se true, qual o minimo }, storage = { active = true, -- Player poderá pegar somente uma vez? key = 91140, -- Apenas uma key por quest }, effectWin = 29, -- Efeito que vai aparecer quando fizer a quest }, }, messages = { notExist = "Essa quest não existe.", win = "Você fez a quest %s.", notWin = "Você já fez a quest %s.", level = "Você precisa de level %d ou maior para fazer a quest %s.", }, } function onUse(cid, item, fromPosition, target, toPosition, isHotkey) local player = Player(cid) local choose = config.quests[item.actionid] if not choose then player:sendCancelMessage(config.messages.notExist) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end if choose.level.active and player:getLevel() < choose.level.min then player:sendCancelMessage(config.messages.level:format(choose.level.min, choose.name)) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end if choose.storage.active and player:getStorageValue(choose.storage.key) >= 0 then player:sendCancelMessage(config.messages.notWin:format(choose.name)) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end for i = 1, #choose.rewards do player:addItem(choose.rewards[i].id, choose.rewards[i].count) end player:setStorageValue(choose.storage.key, 1) player:sendCancelMessage(config.messages.win:format(choose.name)) player:getPosition():sendMagicEffect(choose.effectWin) return true end Para configurar é só utilizar ler os comentários deixados e para adicionar mais quests apenas use o mesmo padrão que deixei aí Utilize a tag no actions.xml desse forma <action fromaid="7171" toaid="7172" script="quests.lua" /> Sendo que o "fromaid" é a actionid inicial, e o "toaid" é a última actionid registrada no arquivo. Qualquer problema, relate nesse tópico.
-
[SafeZone] Evento by Movie & LuanLuciano
Você conferiu se sua versão é 1.x?
- BAIAK 8.6 NOVO - VIP15 - AURA SYSTEM - EVENTOS - MAGIAS NOVAS - REFINAMENTO
-
Mega Sorteio Underwar 13 anos
Desculpe, mas mesmo vocês sendo donos do TibiaKing e UnderWar, EU acho meio nada haver postar nessa seção em que tecnicamente serviria para avisos do TibiaKing. Eu acharia super normal se postasse em algo relacionado a divulgação e tudo mais... Mas essa é apenas a minha opinião, quem manda são vocês.
- [CreatureScript] Sugestão de balanceamento
- [CreatureScript] Sugestão de balanceamento
- [CreatureScript] Sugestão de balanceamento
-
[CreatureScript] Sugestão de balanceamento
Quando você usa com storage, você precisa comparar, porque a storage pode assumir diversos valores. Por exemplo, se você tentar fazer isso, você vai comparar o valor com o que? Isso o lua não entende if player:getStorageValue(1771) then O certo seria if player:getStorageValue(1771) == (valor) then Não sei se conseguiu entender.. caso não tenha entendido me avisa.
- [CreatureScript] Sugestão de balanceamento
-
[TFS 1.X] Dodge & Critical System
Dentro da pasta lib, abra o arquivo lib.lua. No final de tudo adicione -- Dodge e Critical dofile('data/lib/dodgeCritical.lua')
-
[TFS 1.X] Dodge & Critical System
[Dodge & Critical] Sabe aqueles sistemas de dodge e critical que temos nos servidores de baiak? Então, é isso que hoje vou trazer para vocês! Há um sistema disponibilizado na internet, porém não funcional, o que eu fiz foi fixá-lo e adicionar o dodge para mana também. Testado no TFS 1.3 na versão 8.60 Na pasta lib crie um arquivo chamado dodgeCritical.lua --[[ Dodge & Critical fixado por Movie (Movie#4361) Disponibilizado para o TibiaKing e não autorizo outras reproduções Mantenha os créditos <3 --]] STORAGEVALUE_DODGE = 48900 STORAGEVALUE_CRITICAL = 48901 DODGE = { LEVEL_MAX = 100, -- máximo de level que o dodge será PERCENT = 0.2 -- porcentagem que irá defender o ataque } CRITICAL = { LEVEL_MAX = 100, -- máximo de level que o critical será PERCENT = 0.2 -- porcentagem que irá aumentar o ataque } function Player.getDodgeLevel(self) return self:getStorageValue(STORAGEVALUE_DODGE) end function Player.setDodgeLevel(self, value) return self:setStorageValue(STORAGEVALUE_DODGE, value) end function Player.getCriticalLevel(self) return self:getStorageValue(STORAGEVALUE_CRITICAL) end function Player.setCriticalLevel(self, value) return self:setStorageValue(STORAGEVALUE_CRITICAL, value) end Não esqueça de registrar a lib no lib.lua Agora na pasta creaturescript/scripts crie um arquivo chamado dodgeCritical.lua --[[ Dodge & Critical fixado por Movie (Movie#4361) Disponibilizado para o TibiaKing e não autorizo outras reproduções Mantenha os créditos <3 --]] function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) if (not attacker or not creature) then return primaryDamage, primaryType, secondaryDamage, secondaryType end if primaryType == COMBAT_HEALING then return primaryDamage, primaryType, secondaryDamage, secondaryType end if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer()) then primaryDamage = 0 secondaryDamage = 0 creature:say("DODGE!", TALKTYPE_MONSTER_SAY) creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT) end if (attacker:isPlayer() and (attacker:getCriticalLevel() * 3) >= math.random (0, 1000)) then primaryDamage = primaryDamage + math.ceil(primaryDamage * CRITICAL.PERCENT) attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY) creature:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT) end return primaryDamage, primaryType, secondaryDamage, secondaryType end <event type="healthchange" name="DodgeCritical" script="dodgeCritical.lua"/> Agora crie outro arquivo dentro do creaturescripts/scripts com o nome dodgeMana.lua --[[ Dodge & Critical fixado por Movie (Movie#4361) Disponibilizado para o TibiaKing e não autorizo outras reproduções Mantenha os créditos <3 --]] function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) if (not attacker or not creature) then return primaryDamage, primaryType, secondaryDamage, secondaryType end if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer()) then primaryDamage = 0 secondaryDamage = 0 creature:say("DODGE!", TALKTYPE_MONSTER_SAY) creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT) end return primaryDamage, primaryType, secondaryDamage, secondaryType end <event type="manachange" name="DodgeMana" script="dodgeMana.lua"/> Não esqueça de registra no login.lua player:registerEvent("DodgeCritical") player:registerEvent("DodgeMana") Adicione também no login.lua if player:getDodgeLevel() == -1 then player:setDodgeLevel(0) end if player:getCriticalLevel() == -1 then player:setCriticalLevel(0) end Agora na pasta scripts/talkactions crie um arquivo chamado dodgeCritical.lua --[[ Dodge & Critical fixado por Movie (Movie#4361) Disponibilizado para o TibiaKing e não autorizo outras reproduções Mantenha os créditos <3 --]] local dodge = TalkAction("!dodge") local critical = TalkAction("!critical") function dodge.onSay(player, words, param) local skill = player:getDodgeLevel() local message = "DODGE SYSTEM\nO sistema consiste em defender uma porcentagem dos ataques recebidos.\n\nPor Exemplo:\nCada pedra utilizada atribui 0,3% a mais de chance.\nCom 10 pedras, voce tera 3% de chance de defender 50% dos ataques recebidos.\nCom 100 pedras (maximo), voce tera 30% de chance de defender 50% dos ataques recebidos.\nCada pedra que voce usar, sua skill de dodge aumenta em 1 ponto.\n\n------------------\nDodge Skill: [" .. skill .. "/100]" doPlayerPopupFYI(player, message) end dodge:register() function critical.onSay(player, words, param) local skill = player:getCriticalLevel() local message = "CRITICAL SYSTEM\nO sistema consiste em ter uma chance de dar um dano critico.\n\nPor Exemplo:\nCada pedra utilizada atribui 0,3% a mais de chance.\nCom 10 pedras, voce tera 3% de chance de hitar um dano critico dos ataques desferidos ao seu oponente.\nCom 100 pedras (maximo), voce tera 30% de chance de hitar um dano critico dos ataques desferidos ao seu oponente.\nCada pedra que voce usar, sua skill de dodge aumenta em 1 ponto.\n\n------------------\nCritical Skill: [" .. skill .. "/100]" doPlayerPopupFYI(player, message) end critical:register() Pronto, agora você tem o sistema no seu servidor! Curtiu? Dá um REP+ aí
-
Erro: Argument is unsafe, como resolver?
Na verdade, você nem precisa do parametro de player lá, já que você nem usa. Tenta assim: function onUseWeapon(cid, var, player) local chance = math.random(100) if chance <= 20 then combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_VORTEXBOLT) doCombat(cid, combat, var) addEvent(atk9, 200, cid) elseif chance > 20 then combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW) doCombat(cid, combat, var) end end function atk9(cid) local target = getCreatureTarget(cid) local chance2 = math.random(10) if chance2 == 1 then addEvent(atk9, 200, cid) end end
-
Erro: Argument is unsafe, como resolver?
Você tá usando tfs 1.x?
-
Erro: Argument is unsafe, como resolver?
Quando você passa o player como parâmetro do addEvent, você tá passando uma userdata, que é um número mutável. Recomendo você utilizar o id do player, e depois validar o Player usando tipo local player = Player(playerId)
-
[SafeZone] Evento by Movie & LuanLuciano
[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)
-
(Resolvido)Setar storage para todos em uma determinada área
Isso não vai funcionar, o seu código está para quem usa 1.x, no caso dele é 0.x. A ideia é a mesma que ele fez, mas no 0.x creio que não há o getSpectators, terá que fazer um for para x e outro for para y e pegar os players nesse área.