PtokaX forum

Development Section => LUA & PtokaX-Scripting-Interface => Topic started by: Masterload on 16 November, 2003, 00:05:10

Title: is there some kind of countdown timer for newyear ???
Post by: Masterload on 16 November, 2003, 00:05:10
just like to have one :))
Title:
Post by: klownietklowniet on 16 November, 2003, 00:11:18
How would that work? What would the script do?
Title:
Post by: Typhoon on 16 November, 2003, 00:16:58
i think it should only do the counting til the exact date 01-01-04 at time 00:00  ... then type happy new year or somthing...
could be cool  

***Typhoon?
Title:
Post by: kepp on 16 November, 2003, 01:48:35
I think that's imposible
Title:
Post by: plop on 16 November, 2003, 06:40:11
QuoteOriginally posted by kepp
I think that's imposible
no it is posible, just not fully sure yet how 2 make it.
let me think a little about it, got the basic idea in my head.
or maby some1 else whats have a go @ it.
sure is a cool idea.

plop
Title:
Post by: Masterload on 16 November, 2003, 15:31:29
i was thinking somthing like this
countdown from now to 24:00 1-1-2004

(no scripter :P just an idea)

say : a second timer counting back bla bla hours  days left until.....
Happy new .......
can it be done ?
Title:
Post by: kepp on 16 November, 2003, 16:46:48
if it is possible, you will get the script very soon... :)
Plop, can't you store that date n time in a table...
and then let the script get your date and time frpm your computer?
Title: :)
Post by: Masterload on 16 November, 2003, 16:53:47
thxx to you all for your time !
Title:
Post by: Typhoon on 07 December, 2003, 17:11:28
hi Plop  

just woundering if you have figured something out ..
Title:
Post by: plop on 08 December, 2003, 01:56:13
QuoteOriginally posted by Typhoon?
hi Plop  

just woundering if you have figured something out ..
damn i kinda forgot this 1.
good that you help me remember.
still have 24 day's before i'm really 2 late.  lol
while writing this post i fixed the 1st tiny bit.
my hub now shows the amount of day's left before new year on entry.
more 2morrow.

plop
Title:
Post by: kepp on 08 December, 2003, 06:46:48
I can't wait to see how you will solve ths.. :)
Title: lolz.still waiting.....
Post by: Masterload on 08 December, 2003, 13:02:05
had some minor probs here back now....

23 day's left m8,
but the countdown works ?
Title:
Post by: plop on 08 December, 2003, 13:20:25
[12:59] Time left till new year: 23 Day's, 11 Hours, 0 Minutes, 15 Seconds

still some work 2 do on starting/adjusting the timer for the last day.
it now only shows on entry.

btw some ascii would be nice 2 be shown on new year.
would be great if some1 could make that.

plop
Title:
Post by: Optimus on 08 December, 2003, 13:23:20
Yhea guy's give Plop some help, who can make him some (verry Nice) ASCII picture...  ;)
Title:
Post by: [ES]latinmusic on 08 December, 2003, 17:16:19
QuoteOriginally posted by Optimus
Yhea guy's give Plop some help, who can make him some (verry Nice) ASCII picture...  ;)
I, if i have some time
Title:
Post by: SaintSinner on 08 December, 2003, 20:08:39
QuoteOriginally posted by Optimus
Yhea guy's give Plop some help, who can make him some (verry Nice) ASCII picture...  ;)


Found this one on the intanet

_
 _   _                     _    _             _  _             | |
/|   |\                    |\   |\            /  |\            |_|
 |___|  _   _    _         | \  |  _         /   |  _   _  ,_   _
 |   | / | | \  | \  / |   |  \ | /_\ / / |  \___|//_\ / | | ` / \
\|   |/\_|/|_/_/|_/_/\_|  \|   \| \__/\_\_|     /| \__/\_|/|   \_/
     '     |    |     /|        `              ( |
           |    |     \|                        \|
                                                 . `:
                                                : : .
                                                 : .
                                                [""]
                                                |  |
                                                |  |
                                                |  |
                                       :       .'--`.
                   _..-~-.._         : .:     /`.__.'\
                 .'         `.      :    .   /        \
               .'  .-'''''-.  `.   ,-'``'-. ;          ;
              /  ,'   XII   `.  \  |`-..-'| |   ,--.   |
             /  /     /|\     \  \ | .   :| |_.','`.`._|
             | ;       |       ; | | . :  | |--'2004`--|
             | |IX     o    III| | |`-..-'| ||   | | | |
             | ;               ; | \::::::/ ||)|/|)|)|\|
             |  \             /  |  `::::'  |._ ~**~ _.|
       ------|   `.   V I   ,'   |----)(----|  `-..-'  |-------
        _____j     `-.....-'     |    )(    |          |,--.
   ____/ /  /\\ ,-._.--------.-.-' ,-')('-. |          |\`;/
.-()___  :  |`.!,-'`'/`-._  (___) (  '  `  )`-._    _.-'|;,|
`-,    \_\__\`,-'>-.,-._           `-....-'     ````    `--'  
  `-._       (`- `-._`-.`

dammintt wort work in here!!!!!!!
Title:
Post by: SaintSinner on 08 December, 2003, 20:22:05
ok this should work

newyear (http://members.cox.net/saintsinner/newYear.txt)
Title:
Post by: AlwaysConnected on 08 December, 2003, 21:53:07
                    A  
                    < * >                                                             *
 *                  /.-.\         *                   *                  *
          *         /&\                    *
                 ,@.*;@,                                        *                     *                  *
                  /_o.I \    *      
               / ;--.  ,__  ')             *                               *                  *                   *
             ;@ o O,* ' &\
           *  ( '--)_@ ;o ()\      *                 *              Merry Christmas
            / ;--._ ''--._O'@;                                 And A Happy New Year          *
           /&*,() o ;-.,_  "" )                                    To  All Users                        *
          / ,@ ;+& () o* ;-';\                                
         ( ""--.,_0 +@' &()\                       *                          
         /-.,_      ''--....-' )  *                                                                           *
   *    /@o :;'--,.__   __.'\                                                        *
     ;*,&(); @ &^;  " o;@();         *                   *                  
     /(); o^ ; & ().o@*& ;&\                                              *
   "="==""==,,,.,="=="==="                                          
  __.----.(\-''#####---...___...-----


kerst (http://home.planet.nl/~feer0011/ptokax/kerst.txt)

or this one ^
Title:
Post by: kepp on 08 December, 2003, 22:20:36
I can feel Christmas is comming closer when i look at those "pictures" :)
Title:
Post by: plop on 09 December, 2003, 02:47:12
ran a test 2day on 3 different way's of sync-ing, 2 failed.
so rewriten the sync part and should work fine 2morrow.
used a much saver way now.  lol
untill the last hour it should show the time left every hour.
after that it jumps from 15 mins, to 5 mins to 1, to 15 secs, to 5 secs, and starts 2 countdown from 10 to 0 then shows a text file and wishes happy new year from all the folks here on the forum.  lol
pray for me that it all works 2morrow.  lol

have 2 thk chilla allready for his cool julianday with hours,mins, seconds, that made it a lot easyer.

plop
Title:
Post by: pHaTTy on 09 December, 2003, 02:52:17
Sounding nice plop
Title: thxx
Post by: Masterload on 09 December, 2003, 14:23:14
lol  thxx again all for the time ...
hehe feeling the spirrit to here :))

my kids are counting down already
hm, i have to reinstall ,get a working exe
then ill wil try to create a nice ASCII picture's
first time do :P

thxx all in here for ur "time" lolz

sounds great plop :)
Title:
Post by: plop on 10 December, 2003, 00:39:59
tada, tested and working.
------------------------------------------------------------------------------
-------                  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, day
SylYear,SylMonth,SylDay = 03,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
   end
end
------------------------------------------------------------------------------
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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+se
end
------------------------------------------------------------------------------
function TimeLeft()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
local tmp = sylsec-cursec
local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
return ("Time left till new year: "..sylday-curday.." Day's, "..hours.." Hours, "..minutes.." Minutes, "..seconds.." Seconds")
end
------------------------------------------------------------------------------
function ShowAscii()
   text ="\r\n\r\n"
   readfrom(file)
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      text = text..line.."\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 DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == "!daysleft" then
         user:SendData(Bot, TimeLeft().."|")
         return 1
      end
   end
end
------------------------------------------------------------------------------
function NewUserConnected(user)
   user:SendData(Bot, TimeLeft().."|")
end
------------------------------------------------------------------------------
function OpConnected(user)
   user:SendData(Bot, TimeLeft().."|")
end
------------------------------------------------------------------------------
function Main()
SetTimer(100 * 1000)
StartTimer()
   SendToAll(Bot, TimeLeft().."|")
   Sync()
   ShowAscii()
   last = 0
end
------------------------------------------------------------------------------
function Sync()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   if tmp > 3600 then  --- every hours a msg
      adjust = (floor(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 = (floor(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 = (floor(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 = (floor(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 = floor(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 = floor(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
end
------------------------------------------------------------------------------
happy new year.  lol
can offcourse be used for anything you like, birthday's etc...
just enter the date and file name it has 2 show.
script header allready shows it but i'll repeat it.
the text/ascii loads on the start of the bot, this 2 make sure it shows on time as i seen some big ascii's come by.

plop
Title:
Post by: kepp on 10 December, 2003, 00:45:44
Very Nice :D
Title:
Post by: c h i l l a on 10 December, 2003, 08:30:11
really nice one :)).

I like your idea with the smaller timer intervalls when coming nearer to sylvester.
Title:
Post by: TiMeTrAVelleR on 10 December, 2003, 23:13:46
Realy Great job   NICE :D  :D
Title: Problem
Post by: TiMeTrAVelleR on 11 December, 2003, 00:04:31
0:01:19] <:T??:Cy?e??o?> happy new....... damn..=)
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(10 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(9 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(8 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(7 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(6 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(5 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(4 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(3 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(2 Sec)::::::
[00:01:19] ::::::Time:::Left:::Till:::NewYear::(21 Day's)::(0 Hours)::(0 Min)::(1 Sec)::::::
its  gona make a countdown  every  evening now  i gues    hope you can fix this    

TiMe :P
Title:
Post by: plop on 11 December, 2003, 01:14:01
yes notiched it 2day 2. lol
expect a fix tomorow, easy 1 this.

plop
Title:
Post by: plop on 11 December, 2003, 20:21:36
this should do the trick.
------------------------------------------------------------------------------
-------                  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, day
SylYear,SylMonth,SylDay = 03,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
   end
end
------------------------------------------------------------------------------
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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+se
end
------------------------------------------------------------------------------
function TimeLeft()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
local tmp = sylsec-cursec
local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
return ("Time left till new year: "..sylday-curday.." Day's, "..hours.." Hours, "..minutes.." Minutes, "..seconds.." Seconds")
end
------------------------------------------------------------------------------
function ShowAscii()
   text ="\r\n\r\n"
   readfrom(file)
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      text = text..line.."\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 DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == "!daysleft" then
         user:SendData(Bot, TimeLeft().."|")
         return 1
      end
   end
end
------------------------------------------------------------------------------
function NewUserConnected(user)
   user:SendData(Bot, TimeLeft().."|")
end
------------------------------------------------------------------------------
function OpConnected(user)
   user:SendData(Bot, TimeLeft().."|")
end
------------------------------------------------------------------------------
function Main()
SetTimer(100 * 1000)
StartTimer()
   SendToAll(Bot, TimeLeft().."|")
   Sync()
   ShowAscii()
   last = 0
end
------------------------------------------------------------------------------
function Sync()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   local day = sylday-curday
   if day ~= 0 then
      adjust = (floor(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 = (floor(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 = (floor(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 = (floor(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 = (floor(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 = floor(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 = floor(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
   end
end
------------------------------------------------------------------------------
plop
Title:
Post by: Event_Horizon on 11 December, 2003, 20:44:26
Nice Plop... works fine 4 me :D

as i sayed you r a great scripter
Title:
Post by: TiMeTrAVelleR on 11 December, 2003, 21:06:47
Thanks  hope it works  now have to wait till 12   lolzz

 :D
Title: Change?
Post by: Snoris on 11 December, 2003, 21:47:36
What did u change and what was the problem??I got it in my hub and it works lika a clock =] ?(
Title: Thanx
Post by: Flux on 11 December, 2003, 22:14:13
Plop

Thanx for this nice small script for the New Year, I also like it as it can be easily edited for any special announcement.

 :))
Title:
Post by: plop on 11 December, 2003, 23:55:36
QuoteOriginally posted by Snoris
What did u change and what was the problem??I got it in my hub and it works lika a clock =] ?(
i used tmp for syncing the timer, this only held 1 day.
so the script didn't check if it actualy was the last day.
i inserted the next piece of code.
  if day ~= 0 then

      adjust = (floor(mod(minutes, 60))*60)+seconds

      if adjust ~= 0 then

         SetTimer(adjust * 1000)

      else

         SetTimer(3600 * 1000)

      end

   else
-- original sync folows here
as you can see it checks if day is 0, if not it just uses the 1 hour interval on the timer.

it is indeed a kind of clock but it's running backwards 2wards newyear.
on that excact moment it shows a msg (happynewyear.txt)
on the last hour the timer interval gets smaller and smaller resulting in a countdown from 10 to 0.

plop
Title:
Post by: TiMeTrAVelleR on 12 December, 2003, 00:02:09
Oki  works  Great now Job  well done  m8 :D
Title:
Post by: plop on 12 December, 2003, 01:28:37
QuoteOriginally posted by T?M??r?V?ll?R
Oki  works  Great now Job  well done  m8 :D
did you fully test it ???
it's a real problem here 2 change my system clock 2 test this bot fully.

plop
Title:
Post by: TiMeTrAVelleR on 12 December, 2003, 09:01:34
Changde  system klok  and works   ;)
Title:
Post by: plop on 12 December, 2003, 11:34:44
QuoteOriginally posted by T?M??r?V?ll?R
Changde  system klok  and works   ;)
ok good 2 hear.

plop
Title: lol great job !! m8 thxx
Post by: Masterload on 15 December, 2003, 11:56:32
hehe countdown works its running smooth !
thxx plop :)

read somewhere you need some more q for scripts
 now the countdown is running....
this was the idea......
24:00 auto web...

saying happy new year !!!
some fireworks en so on
thxx.. greets from the lua . :)
option ??

again...can this be done ??
(sorry just have a great fantasie :P)
Title:
Post by: yepyepyep4711 on 15 December, 2003, 17:45:07
works great. Just is doesn't stop working after new year's eve : )
so it prints things like:

Zeit bis zum neuen Jahr: -1 Tage, 23 Stunden, 55 Minuten, 0 Sekunden

(yes, I translated it :p)
Title:
Post by: plop on 16 December, 2003, 02:31:43
QuoteOriginally posted by yepyepyep4711
works great. Just is doesn't stop working after new year's eve : )
so it prints things like:

Zeit bis zum neuen Jahr: -1 Tage, 23 Stunden, 55 Minuten, 0 Sekunden

(yes, I translated it :p)
lol the timer does stop.
gues it's the welcome, that indeed doesn't stop.
ok bug fix 2morrow.

plop
Title:
Post by: plop on 17 December, 2003, 17:41:37
it now should stop after newyear. lol
also changed the way it shows, if day's/hours/minutes/seconds == 0 then it's not showing.
looks a bit better @ moments the timer is in sync.
------------------------------------------------------------------------------
-------                  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, day
SylYear,SylMonth,SylDay = 03,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
   end
end
------------------------------------------------------------------------------
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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+se
end
------------------------------------------------------------------------------
function TimeLeft()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
local tmp = sylsec-cursec
local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(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
   else
      return 1
   end
end
------------------------------------------------------------------------------
function ShowAscii()
   text ="\r\n\r\n"
   readfrom(file)
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      text = text..line.."\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 DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == "!daysleft" then
         user:SendData(Bot, TimeLeft().."|")
         return 1
      end
   end
end
------------------------------------------------------------------------------
function NewUserConnected(user)
   local tmp = TimeLeft()
   if tmp ~= 1 then
      user:SendData(Bot, tmp.."|")
   end
end
------------------------------------------------------------------------------
function OpConnected(user)
   local tmp = TimeLeft()
   if tmp ~= 1 then
      user:SendData(Bot, TimeLeft().."|")
   end
end
------------------------------------------------------------------------------
function Main()
   SetTimer(100 * 1000)
   StartTimer()
   local tmp = TimeLeft()
   if tmp ~= 1 then
      SendToAll(Bot, tmp.."|")
   end
   Sync()
   ShowAscii()
   last = 0
end
------------------------------------------------------------------------------
function Sync()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   local day = sylday-curday
   if day ~= 0 then
      adjust = (floor(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 = (floor(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 = (floor(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 = (floor(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 = (floor(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 = floor(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 = floor(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
   end
end
------------------------------------------------------------------------------
plop

* edit: forgot function main.
Title:
Post by: plop on 17 December, 2003, 20:00:22
lol forgot the command also + tiny bug fix.

------------------------------------------------------------------------------
-------                  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, day
SylYear,SylMonth,SylDay = 03,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
   end
end
------------------------------------------------------------------------------
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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+se
end
------------------------------------------------------------------------------
function TimeLeft()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
local tmp = sylsec-cursec
local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(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
   else
      return 1
   end
end
------------------------------------------------------------------------------
function ShowAscii()
   text ="\r\n\r\n"
   readfrom(file)
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      text = text..line.."\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 DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == "!daysleft" then
         local tmp = TimeLeft()
         if tonumber(tmp) == nil then
            user:SendData(Bot, tmp.."|")
         end
         return 1
      end
   end
end
------------------------------------------------------------------------------
function NewUserConnected(user)
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      user:SendData(Bot, tmp.."|")
   end
end
------------------------------------------------------------------------------
function OpConnected(user)
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      user:SendData(Bot, tmp.."|")
   end
end
------------------------------------------------------------------------------
function Main()
SetTimer(100 * 1000)
StartTimer()
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      SendToAll(Bot, tmp.."|")
   end
   Sync()
   ShowAscii()
   last = 0
end
------------------------------------------------------------------------------
function Sync()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   local day = sylday-curday
   if day ~= 0 then
      adjust = (floor(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 = (floor(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 = (floor(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 = (floor(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 = (floor(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 = floor(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 = floor(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
   end
end
------------------------------------------------------------------------------

plop
Title: sorry plop
Post by: civil on 17 December, 2003, 20:11:21
sorry man  :( i didn't read the top of the script carefully.so u r the creator.

the reason that i asked the manual period setting is for example if i want to advertise a thing in the hub by countdown.so i want to set the message period myself.is it possible ?
Title:
Post by: plop on 17 December, 2003, 20:54:18
QuoteOriginally posted by civil
sorry man  :( i didn't read the top of the script carefully.so u r the creator.

the reason that i asked the manual period setting is for example if i want to advertise a thing in the hub by countdown.so i want to set the message period myself.is it possible ?
no need 2 excuse yourself.

it is posible but also tricky, let me try 2 explain it.
elseif tmp > 300 then  -- tmp is the amount of seconds left, this i use 2 change the timer, 300 seconds is 5 minutes.
adjust = (floor(mod(minutes, 5))*60)+seconds -- here i check if the timer is in sync, if not the result is anything but 0
if adjust ~= 0 then -- here i check if the adjustment is needed 2 get back in sync
            SetTimer(adjust * 1000)  -- here is start a timer with the needed seconds 2 get the script back in sync.
         else  -- this is triggered if the script is in sync
            SetTimer(300 * 1000) -- here i change the timer 2 the wanted interval, 300 x 1000 = 5 minutes timer interval.
         end

as you can see it's posible but you need 2 adjust things on several places and 1 thing wrong and it goes nutty.

plop
Title:
Post by: civil on 17 December, 2003, 23:41:20
thank you so much. :)
Title:
Post by: cfc on 22 December, 2003, 00:34:57
ok  i just found this script... i can get the timer to work ok but i can't get the picture to pop up... should a picture pop up?.. i have got a "happynewyear.txt" file in my text filder with a picture in it..... if a picture IS supposed to pop up  what have i got wrong?.....
thanks in advance :)
Title:
Post by: plop on 22 December, 2003, 02:49:29
QuoteOriginally posted by cfc
ok  i just found this script... i can get the timer to work ok but i can't get the picture to pop up... should a picture pop up?.. i have got a "happynewyear.txt" file in my text filder with a picture in it..... if a picture IS supposed to pop up  what have i got wrong?.....
thanks in advance :)
the text file should be in the root of the scripts folder.
on the last moment of the timer the picture/text shows up.
the txt file should be there before the script is started.

plop
Title:
Post by: cfc on 22 December, 2003, 10:38:50
the text file should be in the root of the scripts folder.
on the last moment of the timer the picture/text shows up.
the txt file should be there before the script is started.

plop




thak you plop.. much appre... apreacha...appreaech... i'm very gratefull   works a treat :)
Title:
Post by: Masterload on 23 December, 2003, 02:31:27
verry nice job plop all working on it
this fool has another idea

lol
if there is a good web master......
lol i like to try this. example
on 12:00 midnight goto webby with fire works
happy newyear !!!!

??
Title:
Post by: plop on 23 December, 2003, 12:52:55
QuoteOriginally posted by Masterload
verry nice job plop all working on it
this fool has another idea

lol
if there is a good web master......
lol i like to try this. example
on 12:00 midnight goto webby with fire works
happy newyear !!!!

??
nice idea but the only way dc can open a website is when the user opens it himself. lol

plop
Title: :)
Post by: Masterload on 30 December, 2003, 23:42:56
hehe smoking to much i think
thxx plop great job m8y :)



like to wish all here reading this !!!
happy new year  (back next year.... another topic )
lolz
Title:
Post by: plop on 31 December, 2003, 00:21:29
QuoteOriginally posted by Masterload
hehe smoking to much i think
thxx plop great job m8y :)
thats really bad, you forgot 2 give me some. lol

happy new year 2 u 2

plop
Title: :)
Post by: Masterload on 01 January, 2004, 11:23:11
here u go plop :)
legalize it :P

hehe thxx again

(http://photos.bravenet.com/155/408/555/9689B1E85ETN.gif)