{"id":103,"date":"2025-08-17T19:34:44","date_gmt":"2025-08-17T19:34:44","guid":{"rendered":"https:\/\/ayoocloud.com.br\/blog\/?p=103"},"modified":"2025-08-17T19:34:44","modified_gmt":"2025-08-17T19:34:44","slug":"actions-sistema-de-forja-forging-system-otserv","status":"publish","type":"post","link":"https:\/\/ayoocloud.com.br\/blog\/2025\/08\/17\/actions-sistema-de-forja-forging-system-otserv\/","title":{"rendered":"[Actions] &#8211; Sistema de forja (forging system) Otserv"},"content":{"rendered":"<h3><strong>Esse script \u00e9 um\u00a0<span class=\"mycode_b\">sistema de forja (forging system)<\/span>, ele altera alguns itens do mapa enquanto a forja esta rodando.<\/strong><\/h3>\n<p><strong>Resumo:<\/strong><\/p>\n<ul class=\"mycode_list\">\n<li>O jogador usa uma<span class=\"mycode_b\">\u00a0<\/span>alavanca ou outro item com actionid =<span class=\"mycode_b\">\u00a07787\u00a0<\/span>para iniciar a forja.<\/li>\n<li>Requisitos para ativar:\n<ul class=\"mycode_list\">\n<li><span class=\"mycode_b\">250 Crystal Coins (ID 2159)<\/span><\/li>\n<li><span class=\"mycode_b\">1 Item especial (ID 9019)<\/span><\/li>\n<li><span class=\"mycode_b\">5kk de gold<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Se cumprir os requisitos, os itens s\u00e3o removidos do jogador e o processo come\u00e7a:\n<ul class=\"mycode_list\">\n<li>Os\u00a0<span class=\"mycode_b\">itens do mapa (originalItems)<\/span>\u00a0s\u00e3o substitu\u00eddos por suas vers\u00f5es forjadas (<span class=\"mycode_b\">forgedItems<\/span>) por\u00a0<span class=\"mycode_b\">3 minutos<\/span>.<\/li>\n<li>A cada 10s, \u00e9 enviado um\u00a0<span class=\"mycode_b\">broadcast<\/span>\u00a0avisando que a forja est\u00e1 em andamento.<\/li>\n<li>Ap\u00f3s os 3 minutos, os itens voltam ao estado original.<\/li>\n<li>Dois itens espec\u00edficos do mapa (<span class=\"mycode_b\">toRemoveInPhase2<\/span>) somem por\u00a0<span class=\"mycode_b\">30 segundos<\/span>\u00a0simulando o processo.<\/li>\n<li>Uma\u00a0<span class=\"mycode_b\">nova forja visual<\/span>\u00a0aparece no mapa (<span class=\"mycode_b\">forgeVisual<\/span>) e o jogador recebe a recompensa (<span class=\"mycode_b\">rewardItem<\/span>, Vampire Token, ID 9955) no ch\u00e3o em<br \/>\nrewardDropPos.<\/li>\n<li>Passados 30 segundos, a forja desaparece e os itens da fase 2 s\u00e3o recriados.<\/li>\n<\/ul>\n<\/li>\n<li>O sistema tem\u00a0<span class=\"mycode_b\">cooldown global<\/span>\u00a0para evitar que outro jogador ative a forja enquanto j\u00e1 est\u00e1 em andamento.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Codigo:<br \/>\n[spoiler]<br \/>\nlocal actionId = 7787<br \/>\nlocal requiredItems = {<br \/>\n{id = 2159, count = 250},<br \/>\n{id = 9019, count = 1}<br \/>\n}<br \/>\nlocal requiredMoney = 5000000<br \/>\nlocal rewardItem = 9955<br \/>\nlocal rewardCount = 1<\/p>\n<p>local globalStorageForge = 90000<br \/>\nlocal forgeDuration = 3 * 60 * 1000<br \/>\nlocal forgeCooldown = 20 * 1000<\/p>\n<p>local originalItems = {<br \/>\n{id = 8642, pos = Position(1669, 1992, 7)},<br \/>\n{id = 8654, pos = Position(1670, 1992, 7)},<br \/>\n{id = 8661, pos = Position(1671, 1992, 7)},<br \/>\n{id = 8658, pos = Position(1672, 1992, 7)},<br \/>\n{id = 8660, pos = Position(1672, 1993, 7)},<br \/>\n{id = 8657, pos = Position(1671, 1993, 7)},<br \/>\n{id = 8659, pos = Position(1671, 1994, 7)},<br \/>\n{id = 8658, pos = Position(1672, 1994, 7)},<br \/>\n{id = 8646, pos = Position(1672, 1995, 7)},<br \/>\n{id = 8647, pos = Position(1672, 1996, 7)}<br \/>\n}<\/p>\n<p>local forgedItems = {<br \/>\n{id = 8641, pos = Position(1669, 1992, 7)},<br \/>\n{id = 8673, pos = Position(1670, 1992, 7)},<br \/>\n{id = 8650, pos = Position(1670, 1992, 7)},<br \/>\n{id = 8667, pos = Position(1671, 1992, 7)},<br \/>\n{id = 8664, pos = Position(1672, 1992, 7)},<br \/>\n{id = 8666, pos = Position(1672, 1993, 7)},<br \/>\n{id = 8663, pos = Position(1671, 1993, 7)},<br \/>\n{id = 8665, pos = Position(1671, 1994, 7)},<br \/>\n{id = 8664, pos = Position(1672, 1994, 7)},<br \/>\n{id = 8645, pos = Position(1672, 1995, 7)},<br \/>\n{id = 8643, pos = Position(1672, 1996, 7)}<br \/>\n}<\/p>\n<p>local toRemoveInPhase2 = {<br \/>\n{id = 1526, pos = Position(1670, 1997, 7)}, &#8212; Coloque o ID real<br \/>\n{id = 1526, pos = Position(1670, 1998, 7)}\u00a0 &#8212; Coloque o ID real<br \/>\n}<\/p>\n<p>local forgeVisual = {<br \/>\nid = 8670,<br \/>\npos = Position(1670, 1993, 7)<br \/>\n}<\/p>\n<p>local rewardDropPos = Position(1672, 1998, 7)<\/p>\n<p>function onUse(player, item, fromPosition, target, toPosition, isHotkey)<br \/>\nif item.actionid ~= actionId then<br \/>\nreturn true<br \/>\nend<\/p>\n<p>local currentStorage = Game.getStorageValue(globalStorageForge) or 0<br \/>\nif currentStorage &gt; os.time() then<br \/>\nplayer:sendCancelMessage(&#8220;A forja j\u00e1 est\u00e1 em andamento.&#8221;)<br \/>\nreturn true<br \/>\nend<\/p>\n<p>for _, entry in pairs(requiredItems) do<br \/>\nif player:getItemCount(entry.id) &lt; entry.count then<br \/>\nplayer:sendCancelMessage(&#8220;Voc\u00ea n\u00e3o possui todos os itens necess\u00e1rios.&#8221;)<br \/>\nreturn true<br \/>\nend<br \/>\nend<\/p>\n<p>if not player:removeMoney(requiredMoney) then<br \/>\nplayer:sendCancelMessage(&#8220;Voc\u00ea precisa de 1kk de gold.&#8221;)<br \/>\nreturn true<br \/>\nend<\/p>\n<p>for _, entry in pairs(requiredItems) do<br \/>\nplayer:removeItem(entry.id, entry.count)<br \/>\nend<\/p>\n<p>for i, v in ipairs(originalItems) do<br \/>\nlocal tile = Tile(v.pos)<br \/>\nif tile then<br \/>\nlocal oldItem = tile:getItemById(v.id)<br \/>\nif oldItem then oldItem:remove() end<br \/>\nend<br \/>\nend<\/p>\n<p>for _, v in ipairs(forgedItems) do<br \/>\nGame.createItem(v.id, 1, v.pos)<br \/>\nend<\/p>\n<p>Game.setStorageValue(globalStorageForge, os.time() + ((forgeDuration + forgeCooldown) \/ 1000))<\/p>\n<p>&#8212; Broadcast a cada 10s<br \/>\nfor i = 0, (forgeDuration &#8211; 1), 10000 do<br \/>\naddEvent(function()<br \/>\nbroadcastMessage(player:getName() .. &#8221; est\u00e1 forjando um Vampire Token!&#8221;, MESSAGE_EVENT_ADVANCE)<br \/>\nend, i)<br \/>\nend<\/p>\n<p>addEvent(function()<br \/>\nfor _, v in ipairs(forgedItems) do<br \/>\nlocal tile = Tile(v.pos)<br \/>\nif tile then<br \/>\nlocal tempItem = tile:getItemById(v.id)<br \/>\nif tempItem then tempItem:remove() end<br \/>\nend<br \/>\nend<\/p>\n<p>for _, v in ipairs(originalItems) do<br \/>\nGame.createItem(v.id, 1, v.pos)<br \/>\nend<\/p>\n<p>&#8212; Remover os 2 itens da fase 2<br \/>\nfor _, data in ipairs(toRemoveInPhase2) do<br \/>\nlocal tile = Tile(data.pos)<br \/>\nif tile then<br \/>\nlocal item = tile:getItemById(data.id)<br \/>\nif item then item:remove() end<br \/>\nend<br \/>\nend<\/p>\n<p>&#8212; Remover o item 1945 existente (visualmente) se necess\u00e1rio<br \/>\nlocal forgeTile = Tile(forgeVisual.pos)<br \/>\nlocal forgeItem = forgeTile and forgeTile:getItemById(forgeVisual.id)<br \/>\nif forgeItem then forgeItem:remove() end<\/p>\n<p>&#8212; Recriar forja<br \/>\nlocal createdForge = Game.createItem(forgeVisual.id, 1, forgeVisual.pos)<\/p>\n<p>&#8212; Entrega recompensa no ch\u00e3o<br \/>\nGame.createItem(rewardItem, rewardCount, rewardDropPos)<\/p>\n<p>&#8212; Ap\u00f3s 30s, remove a forja e restaura os dois itens<br \/>\naddEvent(function()<br \/>\nlocal tile = Tile(forgeVisual.pos)<br \/>\nif tile then<br \/>\nlocal existing = tile:getItemById(forgeVisual.id)<br \/>\nif existing then existing:remove() end<br \/>\nend<\/p>\n<p>&#8212; Recria os 2 itens da fase 2<br \/>\nfor _, data in ipairs(toRemoveInPhase2) do<br \/>\nGame.createItem(data.id, 1, data.pos)<br \/>\nend<\/p>\n<p>end, forgeCooldown)<\/p>\n<p>end, forgeDuration)<\/p>\n<p>return true<br \/>\nend<br \/>\n[\/spoiler]<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Fotos:<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/rJ0nzSd\/Captura-de-tela-2025-08-17-144627.png\" alt=\"[Imagem: Captura-de-tela-2025-08-17-144627.png]\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/BK6cxMPC\/Captura-de-tela-2025-08-17-145323.png\" alt=\"[Imagem: Captura-de-tela-2025-08-17-145323.png]\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/xq9wgb9y\/Captura-de-tela-2025-08-17-145637.png\" alt=\"[Imagem: Captura-de-tela-2025-08-17-145637.png]\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong><span class=\"mycode_b\"><span class=\"mycode_size\">Como configurar.<\/span><\/span><\/strong><\/p>\n<p><strong><span class=\"mycode_b\">1-\u00a0Item de ativa\u00e7\u00e3o<\/span><\/strong><\/p>\n<blockquote class=\"mycode_quote\"><p><cite>Cita\u00e7\u00e3o:<\/cite>local actionId = 7787<\/p><\/blockquote>\n<p>Aqui eu utilizo uma alavanca esse 7787 vai na alavanca.<\/p>\n<p><strong><span class=\"mycode_b\">2-\u00a0Requisitos do jogador<\/span><\/strong><\/p>\n<blockquote class=\"mycode_quote\"><p><cite>Cita\u00e7\u00e3o:<\/cite>local requiredItems = {<br \/>\n{id = 2159, count = 250}, &#8212; Crystal Coins<br \/>\n{id = 9019, count = 1}\u00a0 \u00a0 &#8212; Item especial<br \/>\n}<br \/>\nlocal requiredMoney = 5000000 &#8212; Gold necess\u00e1rio<\/p><\/blockquote>\n<p>Define os\u00a0<span class=\"mycode_b\">itens e dinheiro<\/span>\u00a0que o jogador precisa para forjar.<\/p>\n<p><strong><span class=\"mycode_b\">3-\u00a0Recompensa<\/span><\/strong><\/p>\n<blockquote class=\"mycode_quote\"><p><cite>Cita\u00e7\u00e3o:<\/cite>local rewardItem = 9955<br \/>\nlocal rewardCount = 1<br \/>\nlocal rewardDropPos = Position(1672, 1998, 7)<\/p><\/blockquote>\n<p>Item e quantidade da recompensa, e onde ser\u00e1 criada a recompensa qual posi\u00e7\u00e3o.<\/p>\n<p><strong><span class=\"mycode_b\">4-\u00a0Tempos de forja<\/span><\/strong><\/p>\n<blockquote class=\"mycode_quote\"><p><cite>Cita\u00e7\u00e3o:<\/cite>local forgeDuration = 3 * 60 * 1000 &#8212; 3 minutos<br \/>\nlocal forgeCooldown = 20 * 1000\u00a0 \u00a0 &#8212; 20 segundos ap\u00f3s o fim<\/p><\/blockquote>\n<p>Controla quanto tempo dura a forja e quanto tempo demora para resetar totalmente.<\/p>\n<p><strong><span class=\"mycode_b\">5-\u00a0Itens do mapa alterados<\/span><\/strong><\/p>\n<blockquote class=\"mycode_quote\"><p><cite>Cita\u00e7\u00e3o:<\/cite>local originalItems = { &#8230; } &#8212; Itens normais<br \/>\nlocal forgedItems\u00a0 = { &#8230; } &#8212; Vers\u00f5es forjadas<br \/>\nlocal toRemoveInPhase2 = { &#8230; } &#8212; Itens removidos temporariamente<br \/>\nlocal forgeVisual = { id = 8670, pos = Position(1670, 1993, 7) } &#8212; Apar\u00eancia da forja<\/p><\/blockquote>\n<p>Permite trocar os itens que v\u00e3o se transformar no mapa, os que somem na segunda fase e o item visual da forja.<\/p>\n<p><strong><span class=\"mycode_b\">Creditos:<\/span><\/strong><br \/>\nFiapo<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Esse script \u00e9 um\u00a0sistema de forja (forging system), ele altera alguns itens do mapa enquanto a forja esta rodando. Resumo: O jogador usa uma\u00a0alavanca ou outro item com actionid =\u00a07787\u00a0para [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,29,11,22],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-ot-server","category-servidor-dedicado","category-servidor-vps","category-tibia"],"_links":{"self":[{"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":1,"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/posts\/103\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ayoocloud.com.br\/blog\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}