Postado Novembro 10, 2023 1 ano Alguem me ajuda a ajeitar esse error para q o script funcione corretamante porfavor >.< TFS 0.4 8.60 Citar local EventsListalist = { {time = "08:00", name = "Bomberman Event"}, {time = "09:00", name = "Desert War"}, {time = "10:00", name = "Snowball War"}, {time = "11:00", name = "Capture The Flag"}, {time = "12:00", name = "Battlefield Event"}, {time = "13:00", name = "Zombie Event"}, {time = "14:00", name = "Desert War"}, {time = "15:00", name = "Snowball War"}, {time = "16:00", name = "Battlefield Event"}, {time = "17:00", name = "Capture The Flag"}, {time = "18:00", name = "Zombie Event"}, {time = "19:00", name = "Real Castle"}, {time = "21:00", name = "Capture The Flag"}, {time = "22:00", name = "Battlefield Event"}, {time = "22:30", name = "Bomberman Event"}, {time = "23:00", name = "Zombie Event"}, {time = "00:00", name = "Capture The Flag"}, {time = "01:00", name = "Snowball War"}, {time = "02:00", name = "Desert War"}, {time = "03:00", name = "Bomberman Event"} } local position = {x = 708, y = 235, z = 7} function onThink(interval, lastExecution) local people = getPlayersOnline() if #people == 0 then return true end local Count = 0 for _, t in ipairs(EventsListalist) do local eventTime = hourToNumber(t.time) local realTime = hourToNumber(os.date("%H:%M:%S")) if eventTime >= realTime then doPlayerSay(people[1], "Proximo evento as {"..t.time.."h} "..t.name..", faltam "..timeString(eventTime - realTime)..".", TALKTYPE_MONSTER_SAY, false, 0, position) return true end Count = Count + 1 end return true end
Postado Novembro 15, 2023 1 ano Diretor -- Lista de eventos com seus respectivos horários local EventsListalist = { {time = "08:00", name = "Bomberman Event"}, {time = "09:00", name = "Desert War"}, {time = "10:00", name = "Snowball War"}, {time = "11:00", name = "Capture The Flag"}, {time = "12:00", name = "Battlefield Event"}, {time = "13:00", name = "Zombie Event"}, {time = "14:00", name = "Desert War"}, {time = "15:00", name = "Snowball War"}, {time = "16:00", name = "Battlefield Event"}, {time = "17:00", name = "Capture The Flag"}, {time = "18:00", name = "Zombie Event"}, {time = "19:00", name = "Real Castle"}, {time = "21:00", name = "Capture The Flag"}, {time = "22:00", name = "Battlefield Event"}, {time = "22:30", name = "Bomberman Event"}, {time = "23:00", name = "Zombie Event"}, {time = "00:00", name = "Capture The Flag"}, {time = "01:00", name = "Snowball War"}, {time = "02:00", name = "Desert War"}, {time = "03:00", name = "Bomberman Event"} } -- Posição onde os eventos serão anunciados local position = {x = 708, y = 235, z = 7} -- Função para converter o horário de formato "HH:MM" para minutos function hourToNumber(hour) local pattern = "(%d+):(%d+)" local hours, minutes = hour:match(pattern) return tonumber(hours) * 60 + tonumber(minutes) end -- Função para formatar a diferença de tempo em "HH:MM" function timeString(minutes) local hours = math.floor(minutes / 60) local remainingMinutes = minutes % 60 return string.format("%02d:%02d", hours, remainingMinutes) end -- Função chamada a cada intervalo de tempo function onThink(interval, lastExecution) -- Obtém a lista de jogadores online local people = getPlayersOnline() -- Se não houver jogadores online, retorna if #people == 0 then return true end -- Inicializa a contagem local Count = 0 -- Itera sobre a lista de eventos for _, t in ipairs(EventsListalist) do -- Converte os horários dos eventos e o horário atual para minutos local eventTime = hourToNumber(t.time) local realTime = hourToNumber(os.date("%H:%M")) -- Se o horário do evento for maior ou igual ao horário atual if eventTime >= realTime then -- Anuncia o próximo evento e a diferença de tempo doPlayerSay(people[1], "Próximo evento às {"..t.time.."}, "..t.name..", faltam "..timeString(eventTime - realTime)..".", TALKTYPE_MONSTER_SAY, false, 0, position) return true end -- Incrementa a contagem Count = Count + 1 end -- Retorna verdadeiro return true end Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código. #OpenSource #Programação #Contribuição
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.