Peço desculpas caso esteja postando na área errada, por favor movam o tópico. Isso é um tutorial
O script já existe na base que o @WooX postou aqui mas quando tentei passar pro meu sv 0.4 ficava dando debug dai eu desisti na época. Dai eu tava tentando ajudar nesse tópico, tentei mais uma vez e consegui fazer funcionar. Exemplo de como fica ingame
Vamos a instalação
em data/globalevents/scripts crie um arquivo chamado eventcheck.lua e cole isso dentro
local EventsListalist = {
{time = "01:00", name = "Snowball Event"},
{time = "02:00", name = "DesertWar Event"},
{time = "03:00", name = "Capture The Flag"},
{time = "04:00", name = "FireStorm Event"},
{time = "09:00", name = "Defend The Tower"},
{time = "10:00", name = "Snowball Event"},
{time = "11:00", name = "DesertWar Event"},
{time = "12:00", name = "Capture The Flag"},
{time = "13:00", name = "FireStorm Event"},
{time = "15:00", name = "Battlefield Event"},
{time = "16:00", name = "Defend The Tower"},
{time = "17:00", name = "Snowball Event"},
{time = "18:00", name = "DesertWar Event",},
{time = "19:00", name = "Capture The Flag",},
{time = "20:00", name = "FireStorm Event"},
{time = "21:00", name = "Real Castle"},
{time = "22:00", name = "Battlefield Event"},
{time = "23:00", name = "Defend The Tower"}
}
local position = {x = 129, y = 58, z = 7} -- posição do mapa onde o efeito vai sair
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
doCreatureSay(people[1], "Proximo evento as {"..t.time.."h} "..t.name..", faltam "..timeString(eventTime - realTime)..".", TALKTYPE_ORANGE_1, false, 0, position) -- não use acentos aqui ou eles serão alterados por simbolos ingame
return true
end
Count = Count + 1
end
return true
end
Em data/globalevents/globalevents.xml adicione
<globalevent name="eventos" interval="10000" event="script" value="eventcheck.lua"/>
Depois adicione no fim de data/lib/050-function.lua
function hourToNumber(str) -- By Killua
local hour = (tonumber(str:sub(1,2))*3600) + (tonumber(str:sub(4,5)) * 60)
if #str > 5 then
hour = hour + tonumber(str:sub(7,8))
end
return hour
end
function timeString(timeDiff,english) -- créditos: Killua
local dateFormat = {}
if english then
dateFormat = {
{"day", timeDiff / 60 / 60 / 24},
{"hour", timeDiff / 60 / 60 % 24},
{"minute", timeDiff / 60 % 60},
{"second", timeDiff % 60}
}
else
dateFormat = {
{"dia", timeDiff / 60 / 60 / 24},
{"hora", timeDiff / 60 / 60 % 24},
{"minuto", timeDiff / 60 % 60},
{"segundo", timeDiff % 60}
}
end
local out = {}
for k, t in ipairs(dateFormat) do
local v = math.floor(t[2])
if(v > 0) then
table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
end
end
return table.concat(out)
end
Créditos:
@WooX que postou a base onde eu peguei o script
Aparentemente o Killua que criou a função hourToNumber
Seja lá quem criou o script, tem o nome de um tal "Henrique" no arquivo original, talvez tenha sido ele
E eu por algumas pequenas alterações pra fazer o script funcionar em tfs 0.4
CASO VOCÊ QUEIRA O MESMO SISTEMA PARA OTX 2 PROVAVELMENTE O DA BASE POSTADO PELO WOOX VAI FUNCIONAR desde que você adicione o hourToNumber na lib