READ THE RULES
0 Members and 1 Guest are viewing this topic.
------------------------------------------------------------------------------------- Lua 5 version by jiten -------------- countdown bot by plop -------------- original julian day made by tezlo -------------- modifyd by chilla 2 also handle hours, mins, seconds -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- THE TEXT FILE LOADS ON BOT START -------------------------------------------------------------------------------------------- this may sound weird but this 2 make sure it shows on time, -------------- as i allready seen some big ascii's come by -------------------------------------------------------------------------------------------------------------------------------------------------------------------Bot = "newyear"--This the date the timer has 2 stop @ midnight-- year (2 numbers), month, daySylYear,SylMonth,SylDay = 05,12,31-- this is the file 2 be shown file = "happynewyear.txt"------------------------------------------------------------------------------------------------------------------------------------------------------------function OnTimer() if last == 0 then SendToAll(Bot, TimeLeft()) Sync() elseif last == 1 then SendAscii() -- send the msg StopTimer() -- kill the timer endend------------------------------------------------------------------------------function jdatehms(d, m, y,ho,mi,se) local a, b, c = 0, 0, 0 if m <= 2 then y = y - 1 m = m + 12 end if (y*10000 + m*100 + d) >= 15821015 then a = math.floor(y/100) b = 2 - a + math.floor(a/4) end if y <= 0 then c = 0.75 end return math.floor(365.25*y - c) + math.floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+seend------------------------------------------------------------------------------function TimeLeft() local curday,cursec = jdatehms(tonumber(os.date("%d")),tonumber(os.date("%m")),tonumber(os.date("%y")),tonumber(os.date("%H")),tonumber(os.date("%M")),tonumber(os.date("%S"))) local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0) local tmp = sylsec-cursec local hours, minutes,seconds = math.floor(math.mod(tmp/3600, 60)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60)) local day = sylday-curday if day >= 0 then line = "Time left till new year:" if day ~= 0 then line = line.." "..day.." Day's" end if hours ~= 0 then line = line.." "..hours.." Hours" end if minutes ~= 0 then line = line.." "..minutes.." Minutes" end if seconds ~= 0 then line = line.." "..seconds.." Seconds" end return line endend------------------------------------------------------------------------------function ShowAscii() local f = io.open(file) if f then text = f:read("*all") f:close() return string.gsub( text, "\n", "\r\n" ) end end------------------------------------------------------------------------------function SendAscii() SendToAll(Bot, text.." |") SendToAll(Bot, "happy new year 2 everybody from all the guy's/girls/bot's from the lua forum|")end------------------------------------------------------------------------------function ChatArrival(user, data) data=string.sub(data,1,-2) s,e,cmd = string.find(data,"%b<>%s+(%S+)") if cmd == "!daysleft" then local tmp = TimeLeft() if tonumber(tmp) == nil then user:SendData(Bot, tmp.."|") end return 1 endend------------------------------------------------------------------------------function NewUserConnected(user) local tmp = TimeLeft() if tonumber(tmp) == nil then user:SendData(Bot, tmp.."|") endend------------------------------------------------------------------------------OpConnected = NewUserConnected------------------------------------------------------------------------------function Main() SetTimer(100 * 1000) StartTimer() local tmp = TimeLeft() if tonumber(tmp) == nil then SendToAll(Bot, tmp.."|") end Sync() ShowAscii() last = 0end------------------------------------------------------------------------------function Sync() local curday,cursec = jdatehms(tonumber(os.date("%d")),tonumber(os.date("%m")),tonumber(os.date("%y")),tonumber(os.date("%H")),tonumber(os.date("%M")),tonumber(os.date("%S"))) local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0) local tmp = sylsec-cursec local hours, minutes,seconds = math.floor(math.mod(tmp/3600, 60)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60)) local day = sylday-curday if day ~= 0 then adjust = (math.floor(math.mod(minutes, 60))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(3600 * 1000) end else if tmp > 3600 then --- every hours a msg adjust = (math.floor(math.mod(minutes, 60))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(3600 * 1000) end elseif tmp > 900 then -- every 15 mins a msg adjust = (math.floor(math.mod(minutes, 15))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(900 * 1000) end elseif tmp > 300 then -- every 5 mins a msg adjust = (math.floor(math.mod(minutes, 5))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(300 * 1000) end elseif tmp > 60 then -- every min a msg adjust = (math.floor(math.mod(minutes, 1))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(60 * 1000) end elseif tmp > 15 then -- every 15 secs a msg adjust = math.floor(math.mod(seconds, 15)) if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(15 * 1000) end elseif tmp > 10 then -- every 10 secs a msg adjust = math.floor(math.mod(seconds, 10)) if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(5 * 1000) end elseif tmp > 1 then SetTimer(1 * 1000) else last = 1 SetTimer(1 * 1000) end endend------------------------------------------------------------------------------
Originally posted by kash© As it is countdown for new year...,Is it possiblt to have coundown for anycustom date which can be changedFor e.g. countdown for 26 may...instead 31 decRegards
--This the date the timer has 2 stop @ midnight-- year (2 numbers), month, daySylYear,SylMonth,SylDay = 05,12,31
--This the date the timer has 2 stop @ midnight-- year (2 numbers), month, daySylYear,SylMonth,SylDay = 05,12,31 <<<<<< Alter date-- this is the file 2 be shown file = "happynewyear.txt"
Originally posted by kash© How to enable that ascii ??
because of motd..that msg cannot be seen as it goes upwards
Originally posted by kash© It displays countdown time every one hourI wanna edit it and change that time intervalHow can it be done ????Regards...
if day ~= 0 then adjust = (math.floor(math.mod(minutes, 60))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(3600 * 1000) end
Originally posted by kash© Is it possible to display that messageafter MOTD...because of MOTD, that message can not be seen as it goes upwards Regards
Originally posted by jiten QuoteOriginally posted by kash© Is it possible to display that messageafter MOTD...because of MOTD, that message can not be seen as it goes upwards RegardsIt's possible, but, if I am not wrong, it would mess up all the other timers, and so, all the script.Cheers
Originally posted by Dessamator hmm, theres another way, disabling the motd from ptokax, and sending it via the script, just like a normal text,
Originally posted by kash© Jiten can u plz. helpregarding this script,waiting reply....
------------------------------------------------------------------------------------- Lua 5 version by jiten -------------- countdown bot by plop -------------- original julian day made by tezlo -------------- modifyd by chilla 2 also handle hours, mins, seconds -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- THE TEXT FILE LOADS ON BOT START -------------------------------------------------------------------------------------------- this may sound weird but this 2 make sure it shows on time, -------------- as i allready seen some big ascii's come by --------------------------------------------------------------------------------------- Added: Hour,Min,Sec variables, make's it possibole to count to another time then midnight, Madman 10.11.06-- Added: 5.1 support, Madman 10.11.06------------------------------------------------------------------------------Bot = "newyear"--This the date the timer has 2 stop-- year (2 numbers), month, daySylYear,SylMonth,SylDay = 05,12,31--This is the time-- Hour, minute, secondSylHour,SylMin,SylSec = 24,00,00-- this is the file 2 be shown file = "happynewyear.txt"------------------------------------------------------------------------------if math.mod == nil then math.mod = math.fmod end ------------------------------------------------------------------------------function OnTimer() if last == 0 then SendToAll(Bot, TimeLeft()) Sync() elseif last == 1 then SendAscii() -- send the msg StopTimer() -- kill the timer endend------------------------------------------------------------------------------function jdatehms(d, m, y,ho,mi,se) local a, b, c = 0, 0, 0 if m <= 2 then y = y - 1 m = m + 12 end if (y*10000 + m*100 + d) >= 15821015 then a = math.floor(y/100) b = 2 - a + math.floor(a/4) end if y <= 0 then c = 0.75 end return math.floor(365.25*y - c) + math.floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+seend------------------------------------------------------------------------------function TimeLeft() local curday,cursec = jdatehms(tonumber(os.date("%d")),tonumber(os.date("%m")),tonumber(os.date("%y")),tonumber(os.date("%H")),tonumber(os.date("%M")),tonumber(os.date("%S"))) local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,SylHour,SylMin,SylSec) local tmp = sylsec-cursec local hours, minutes,seconds = math.floor(math.mod(tmp/3600, 60)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60)) local day = sylday-curday if day >= 0 then line = "Time left till new year:" if day ~= 0 then line = line.." "..day.." Day's" end if hours ~= 0 then line = line.." "..hours.." Hours" end if minutes ~= 0 then line = line.." "..minutes.." Minutes" end if seconds ~= 0 then line = line.." "..seconds.." Seconds" end return line endend------------------------------------------------------------------------------function ShowAscii() local f = io.open(file) if f then text = f:read("*all") f:close() return string.gsub( text, "\n", "\r\n" ) end end------------------------------------------------------------------------------function SendAscii() SendToAll(Bot, text.." |") SendToAll(Bot, "happy new year 2 everybody from all the guy's/girls/bot's from the lua forum|")end------------------------------------------------------------------------------function ChatArrival(user, data) data=string.sub(data,1,-2) s,e,cmd = string.find(data,"%b<>%s+(%S+)") if cmd == "!daysleft" then local tmp = TimeLeft() if tonumber(tmp) == nil then user:SendData(Bot, tmp.."|") end return 1 endend------------------------------------------------------------------------------function NewUserConnected(user) local tmp = TimeLeft() if tonumber(tmp) == nil then user:SendData(Bot, tmp.."|") endend------------------------------------------------------------------------------OpConnected = NewUserConnected------------------------------------------------------------------------------function Main() SetTimer(100 * 1000) StartTimer() local tmp = TimeLeft() if tonumber(tmp) == nil then SendToAll(Bot, tmp.."|") end Sync() ShowAscii() last = 0end------------------------------------------------------------------------------function Sync() local curday,cursec = jdatehms(tonumber(os.date("%d")),tonumber(os.date("%m")),tonumber(os.date("%y")),tonumber(os.date("%H")),tonumber(os.date("%M")),tonumber(os.date("%S"))) local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,SylHour,SylMin,SylSec) local tmp = sylsec-cursec local hours, minutes,seconds = math.floor(math.mod(tmp/3600, 60)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60)) local day = sylday-curday if day ~= 0 then adjust = (math.floor(math.mod(minutes, 60))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(3600 * 1000) end else if tmp > 3600 then --- every hours a msg adjust = (math.floor(math.mod(minutes, 60))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(3600 * 1000) end elseif tmp > 900 then -- every 15 mins a msg adjust = (math.floor(math.mod(minutes, 15))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(900 * 1000) end elseif tmp > 300 then -- every 5 mins a msg adjust = (math.floor(math.mod(minutes, 5))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(300 * 1000) end elseif tmp > 60 then -- every min a msg adjust = (math.floor(math.mod(minutes, 1))*60)+seconds if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(60 * 1000) end elseif tmp > 15 then -- every 15 secs a msg adjust = math.floor(math.mod(seconds, 15)) if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(15 * 1000) end elseif tmp > 10 then -- every 10 secs a msg adjust = math.floor(math.mod(seconds, 10)) if adjust ~= 0 then SetTimer(adjust * 1000) else SetTimer(5 * 1000) end elseif tmp > 1 then SetTimer(1 * 1000) else last = 1 SetTimer(1 * 1000) end endend------------------------------------------------------------------------------
Would it be fairly easy to change constant (of time, currently set to midnight), to a varible, this would be very helpful for having meetings and such, with all the different time zones, ppl get very easy confused.. so if I could set the date, and time of meeting, and have it count down this could rock.. Also.. can it be used safely in DCDM or any other LUA script client that supports Lua 5?
SylYear,SylMonth,SylDay = 05,12,31