This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Is It Possible ??

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Is It Possible ??

Post by COBRa »

I run a script where people have a certain time to perform a task.

The task starts monday 1 min past midnight and ends sunday midnight what i would like to do is something like this as a point of reference for them

If it was monday the guys would have 7 days to go
If it was tuesday the guys would have 6 days to go etc etc

so as the week progresses the display would show

7 Day/s Left to go
6 Day/s Left to go
5 Day/s Left to go
4 Day/s Left to go

and tomorrow it would show

3 Day/s Left to go

im a total noob and wondered if it could be done

many thx in advance
Online
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: Is It Possible ??

Post by willyw »

COBRa wrote: ...
so as the week progresses the display would show

...
When? Once? Right after midnight? .... or what?
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

the countdown for the week would be constantly displayed so as the week progresses it would count down by day until the week is over

so as of sunday 00.01 the display would show

7 day/s to go

then as of monday 00.01 the display would show

6 day/s to go and so on till the week is over then then rest itsself as to start again

hope tht makes sence
Online
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

COBRa wrote:the countdown for the week would be constantly displayed so as the week progresses it would count down by day until the week is over

so as of sunday 00.01 the display would show

7 day/s to go

then as of monday 00.01 the display would show

6 day/s to go and so on till the week is over then then rest itsself as to start again

hope tht makes sence
Not really.
You said, "constantly" - which means just that. Basically - a flood. Making an announcement something like once per every two seconds.

Then you re-iterated what you had already said, pretty much. That part says that you want it to announce once per day.

But anyway - here you go:

Code: Select all


# Feb. 24, 2015
#  http://forum.egghelp.org/viewtopic.php?p=103540#103540


###########

#set the channel in which to do the announcement
set announce_chan #eggdrop

###########




###########

bind cron - "01 00 * * 0" sunday_announce
bind cron - "01 00 * * 1" monday_announce
bind cron - "01 00 * * 2" tuesday_announce
bind cron - "01 00 * * 3" wednesday_announce
bind cron - "01 00 * * 4" thursday_announce
bind cron - "01 00 * * 5" friday_announce
bind cron - "01 00 * * 6" saturday_announce


proc sunday_announce {min hour day month weekday} {
global announce_chan
        putserv "privmsg $announce_chan :7 day/s to go"
}

proc monday_announce {min hour day month weekday} {
global announce_chan
        putserv "privmsg $announce_chan :6 day/s to go"

}

proc tuesday_announce {min hour day month weekday} {
global announce_chan
        putserv "privmsg $announce_chan :5 day/s to go"
}
proc wednesday_announce {min hour day month weekday} {
global announce_chan
        putserv "privmsg $announce_chan :4 day/s to go"
}

proc thursday_announce {min hour day month weekday} {
global announce_chan
        putserv "privmsg $announce_chan :3 day/s to go"
}

proc friday_announce {min hour day month weekday} {
global announce_chan
        putserv "privmsg $announce_chan :2 day/s to go"
}

proc saturday_announce {min hour day month weekday} {
global announce_chan
        putserv "privmsg $announce_chan :1 day to go"
}

This should make the announcement at 1 min past midnight.
Once daily.

With very brief testing, it works for me.

Test it.

I hope this helps.
Online
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Here is another way to do it.
There are probably lots more, too.

Code: Select all


# Feb. 24, 2015
#  http://forum.egghelp.org/viewtopic.php?p=103540#103540


####

#set the channel in which to do the announcement
set announce_chan #eggdrop

###########



bind cron - "01 00 * * *" days2go_announce


proc days2go_announce {min hour day month weekday} {
global announce_chan

        if {[strftime %u] == "6"} {
                putserv "privmsg $announce_chan :1 day to go"
           }

        if {[strftime %u] == "5"} {
                putserv "privmsg $announce_chan :2 days to go"
           }

        if {[strftime %u] == "4"} {
                putserv "privmsg $announce_chan :3 days to go"
           }

        if {[strftime %u] == "3"} {
                putserv "privmsg $announce_chan :4 days to go"
           }

        if {[strftime %u] == "2"} {
                putserv "privmsg $announce_chan :5 days to go"
           }

        if {[strftime %u] == "1"} {
                putserv "privmsg $announce_chan :6 days to go"
           }

        if {[strftime %u] == "0"} {
                putserv "privmsg $announce_chan :7 days to go"
           }

}

User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Yeah, instead of multiple if statements you could go with switch. :) Apart this, good idea willyw.

I was thinking at something similar to be honest when read the first post, but after I have read your post I was thinking why not get creative and pull a rabbit out of the hat.

Code: Select all

bind cron - "01 00 * * *" days2go:announce

proc days2go:announce {min hour day month weekday} {
	set days [expr 7 - [strftime %u]]
	puthelp "privmsg #announce_chan :[expr {$days==1?"1 day":"$days days"}] to go!"
}
Not 100% sure and can't test right now, but i think we can use $day variable as well but I'd expect it to have an leading zero, but no problem with that. ;)
Once the game is over, the king and the pawn go back in the same box.
Online
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

caesar wrote: Yeah, instead of multiple if statements you could go with switch. :) Apart this, good idea willyw.
I was hoping that it might be so easy to follow that the original poster would be wanting to explore learning some basic TCL for him/her self.
...
Not 100% sure and can't test right now, but i think we can use $day variable as well but I'd expect it to have an leading zero, but no problem with that. ;)
Did you mean to say $weekday?

If so, then yes - I had flirted with using it, instead of strftime. I believe it does contain a leading zero, and I don't know what it does on Sunday, and didn't want to try to change dates on a shell, etc. to experiment and find out. Then there may have been need to deal with the leading zero, and I just wanted the thing to be so simple that the flow of what was going on was easy to see.

I hope it works out for the original poster, and that they jump in and try some basic TCL soon.
:)
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

many thx guys both versions work for me im in the process of adding to my script with a couple of modifications once i get it running i'll post the final draft or report any difficulties

Many thx once again
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The expr will have no problem with any leading zeroes.
Once the game is over, the king and the pawn go back in the same box.
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

Code: Select all

bind cron - "01 00 * * *" days2go:announce

proc days2go:announce {min hour day month weekday} {
	set days [expr 7 - [strftime %u]]
	puthelp "privmsg #announce_chan :[expr {$days==1?"1 day":"$days days"}] to go!"
}
Using this code instead of the announce line is it possible to make a variable so I can incorporate it into another announce line?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Sure, just move out the

Code: Select all

[expr {$days==1?"1 day":"$days days"}]
to a variable

Code: Select all

set days2go [expr {$days==1?"1 day":"$days days"}]
like this, and if you want to use $days2go in another proc then define it globally

Code: Select all

proc days2go:announce {min hour day month weekday} { 
global days2go
... rest of the code
and the same global days2go in any other proc you want.
Once the game is over, the king and the pawn go back in the same box.
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

Many thx for the swift reply but I have an issue is bind cron supported in ver 1.6.21 as it kills the bot when I add the cron line if not could it be done with bind time plz
Online
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

COBRa wrote: ... is bind cron supported in ver 1.6.21...
Yes.
...as it kills the bot...
This is not enough information for us to be able to try to help you.

Describe everything that you see when it happens.
Especially from the partyline. (Check your console flags, and be sure that any that could possibly help you see things, are On.)
...when I add the cron line ...
This is not enough information for us to be able to try to help you.
Show us the line(s) in question.
... if not could it be done with bind time plz
Maybe. We can't guess as to which way might be best, until we see what you are trying to do.

You mentioned that you have modified the code from what I wrote. If the cron bind is somehow causing a problem, I'm assuming that is part of what you modified, because it did not cause a problem when I quickly tested it. I tested it on a version 1.6.21 bot.
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

many thx guys for all your help ive got it working just fine now
Post Reply