-- =========================================================================== -- Leilao - contador na tela enquanto ha leilao aberto (pedido do dono em 24/10/2026; no molde do NpcMalucoTimer) -- Quem manda e o servidor (Data/Script/Scripts/Leilao.lua): o pacote LE_Estado chega quando o leilao abre, a cada -- lance, quando acaba e a quem entra no jogo com leilao aberto. Aqui so desenha. -- -- LE_Estado (so numeros): segundos que faltam (0 = acabou), moeda (1 Cash, 2 Obsidian), valor (o minimo, ou o do -- ultimo lance), tem lance (0 ou 1), e o nome do item e o do lider como tamanho + uma letra por numero. -- -- Painel no topo da tela, no centro. Em 84 (abaixo do NPC Maluco) o nome dos jogadores no mapa passava por cima dele -- (print do dono, 24/10/2026): o jogo desenha os nomes depois do Lua. Com o leilao no ar, o contador do NPC Maluco -- desce para baixo deste (MO_LeilaoAberto). A largura da tela vem do Scripts/Comum/Tela.lua (wide e 4:3). -- =========================================================================== local IMG_FUNDO = 40060 -- Custom\Interface\UX_Confirmar.tga (220 x 104), o fundo da confirmacao da lixeira local LARG, ALT = 220, 72 local Y = 4 local MOEDA = { [1] = "Cash", [2] = "Obsidian" } local E = nil -- { fim, moeda, valor, lance, item, lider } function MO_LeilaoAberto() if not E then return false end local ok, t = pcall(os.time) return ok and E.fim > t end MO_LeilaoAltura = 4 + 72 + 4 -- o NPC Maluco desce para ca enquanto ha leilao local function Agora() local ok, t = pcall(os.time) return ok and t or 0 end local function CentroX() return MO_CentroX and MO_CentroX() or math.floor((GetWideX() + 320) / 2) end local LerForma = nil local function LerDword(nome) local formas = { function() return GetDwordPacket(nome) end, function() return GetDwordPacket(nome, -1) end } if LerForma then local ok, v = pcall(formas[LerForma]); if ok then return tonumber(v) end end for i, f in ipairs(formas) do local ok, v = pcall(f) if ok and tonumber(v) then LerForma = i; return tonumber(v) end end return nil end local function LerTexto(nome) local n = math.min(LerDword(nome) or 0, 60) local t = {} for i = 1, n do local c = LerDword(nome) if c and c >= 32 and c < 256 then t[#t + 1] = string.char(c) end end return table.concat(t) end local function Protocolo(head, nome) if nome ~= "LE_Estado" then return nil end local s = LerDword(nome) or 0 local moeda, valor, lance = LerDword(nome) or 0, LerDword(nome) or 0, LerDword(nome) or 0 local item = LerTexto(nome) local lider = LerTexto(nome) pcall(ClearPacket, nome) if s > 0 then E = { fim = Agora() + s, moeda = MOEDA[moeda] or "", valor = valor, lance = lance == 1, item = item, lider = lider } else E = nil end return true end ProtocolFunctions.ClientProtocol(Protocolo) function Leilao_Desenhar() if not E then return end local resta = E.fim - Agora() if resta <= 0 then return end -- o servidor manda o fim; ate la fica em 0:00 local x = CentroX() - math.floor(LARG / 2) pcall(RenderImage2, IMG_FUNDO, x, Y, LARG, ALT, 0, 0, 220 / 256, 104 / 128, 1, 1, 1.0) SetFontType(1); SetTextBg(0, 0, 0, 0) SetTextColor(255, 189, 25, 255) RenderText5(x, Y + 7, "Leil\227o: " .. E.item, LARG, 3) if resta <= 10 then SetTextColor(255, 80, 80, 255) else SetTextColor(255, 255, 255, 255) end RenderText5(x, Y + 22, string.format("%d:%02d", math.floor(resta / 60), resta % 60), LARG, 3) SetTextColor(255, 255, 255, 255) if E.lance then RenderText5(x, Y + 37, string.format("%s: %d %s", E.lider, E.valor, E.moeda), LARG, 3) else RenderText5(x, Y + 37, string.format("Lance m\237nimo: %d %s", E.valor, E.moeda), LARG, 3) end SetTextColor(190, 190, 190, 255) RenderText5(x, Y + 53, "/lance ", LARG, 3) end function Leilao_Carregar() pcall(LoadBitmap, "Custom\\Interface\\UX_Confirmar.tga", IMG_FUNDO) end BridgeFunctionAttach('MainLoader', 'Leilao_Carregar') BridgeFunctionAttach('MainInterfaceProcThread', 'Leilao_Desenhar')