CountDown Script!
 

News:

11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

CountDown Script!

Started by Hades, 16 May, 2005, 01:06:57

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hades

Could someone modify countdown - happy new year script to lua 5??




THANX!

Dessamator

yep sure, just show us which script u want modded, btw try converting it using the gui converter !
Ignorance is Bliss.

plop

http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

jiten

#3
Here goes a fast one (not tested):
------------------------------------------------------------------------------
-------                  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, day
SylYear,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
	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 = 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+se
end
------------------------------------------------------------------------------
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
	end
end
------------------------------------------------------------------------------
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
	end
end
------------------------------------------------------------------------------
function NewUserConnected(user)
	local tmp = TimeLeft()
	if tonumber(tmp) == nil then user:SendData(Bot, tmp.."|") end
end
------------------------------------------------------------------------------
OpConnected = NewUserConnected
------------------------------------------------------------------------------
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(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
	end
end
------------------------------------------------------------------------------

Cheers

Dessamator

hmm, nice one jiten, less work for me, :)
Ignorance is Bliss.

TiMeTrAVelleR

Got this in main  at ful hour

[14:00:00] 1


greetzzz TT

jiten

First post updated.

Cheers

TiMeTrAVelleR

[15:00:00] Time left till new year: 229 Days 9 Hours

works  fine  thanks  jiten

Greetzzz TT

jiten

You're welcome TT :]

kash?

#9
As it is countdown for new year...,
Is it possiblt to have coundown for any
custom date which can be changed
For e.g. countdown for 26 may...instead 31 dec

Regards

jiten

QuoteOriginally posted by kash?
As it is countdown for new year...,
Is it possiblt to have coundown for any
custom date which can be changed
For e.g. countdown for 26 may...instead 31 dec

Regards
Just edit this in the Countdown script with your desired "finish" date:
--This the date the timer has 2 stop @ midnight
-- year (2 numbers), month, day
SylYear,SylMonth,SylDay = 05,12,31
Cheers

Tw?sT?d-d?v

#11
QuoteOriginally posted by kash?
As it is countdown for new year...,
Is it possiblt to have coundown for any
custom date which can be changed
For e.g. countdown for 26 may...instead 31 dec

Regards

yes m8  just alter this part of the script for the date you require...
--This the date the timer has 2 stop @ midnight
-- year (2 numbers), month, day
SylYear,SylMonth,SylDay = 05,12,31   <<<<<<   Alter date
-- this is the file 2 be shown 
file = "happynewyear.txt"

MMM beat me to it       :D

Hades

This board still rulez!


Regards!

kash?

#13
How to enable that ascii ??
Is it possible to show that countdown
timer in main chat at short interval with editable
time interval.......because of motd..that msg can
not be seen as it goes upwards



Regards

jiten

QuoteOriginally posted by kash?
How to enable that ascii ??
You need to create a file named "happynewyear.txt" in your script's main folder and then put the ASCII inside.
Quotebecause of motd..that msg cannot be seen as it goes upwards
Indeed. I'm going to change it so that it will come after the MOTD (maybe tomorrow).

Cheers

kash?

It displays countdown time every one hour
I wanna edit it and change that time interval
How can it be done ????

Regards...

plop

QuoteOriginally posted by kash?
It displays countdown time every one hour
I wanna edit it and change that time interval
How can it be done ????

Regards...

find the next lines in the sync() function.
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
exchange 3600 for your prefered setting (3600 * 1000 = 1 hour in seconds).
but remember it's the syncronisation your messing with.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

kash?

Is it possible to display that message
after MOTD...
because of MOTD, that message can
not be seen as it goes upwards

Regards

dkt

just try changing the order in ptokax script editor...
use move up ..move down..
keep ur countdown script last
it shld work...as it worked for other scripts though

kash?

It doesn't work

jiten

QuoteOriginally posted by kash?
Is it possible to display that message
after MOTD...
because of MOTD, that message can
not be seen as it goes upwards

Regards
It's possible, but, if I am not wrong, it would mess up all the other timers, and so, all the script.

Cheers

Dessamator

QuoteOriginally posted by jiten
QuoteOriginally posted by kash?
Is it possible to display that message
after MOTD...
because of MOTD, that message can
not be seen as it goes upwards

Regards
It's possible, but, if I am not wrong, it would mess up all the other timers, and so, all the script.

Cheers

hmm, theres another way, disabling the motd from ptokax, and sending it via the  script, just like a normal text,  ;)
Ignorance is Bliss.

jiten

QuoteOriginally posted by Dessamator
hmm, theres another way, disabling the motd from ptokax, and sending it via the  script, just like a normal text,  ;)
Or sending the MOTD in PM too ;)

kash?

Can u plz try
if u have time
I really need this script and that too after MOTD
please have a try if u knw how to do it
take ur time

waiting for reply
Posted on: 20 May 2005, 19:35:16
Jiten can u plz. help
regarding this script,

waiting reply....

jiten

QuoteOriginally posted by kash?
Jiten can u plz. help
regarding this script,

waiting reply....
Well, I don't want to modify the timers because it would mess all the script up. So, here's my hint:

  • In your PtokaX gui, go to Network Tab and tick "Send MOTD in PM".

By doing this, you'll be sending the MOTD in PM and, logicaly, it won't come after the CountDown stats like it used to happen.
That's all I can do unless someone else has a better idea ;)

Cheers

SMF spam blocked by CleanTalk