Simple time script, one of the first scripts I've made, newbie scripter.
Constructive criticism welcome (:
on *:text:*:#: {
if !%t { inc -u5 %t
if ($strip($1) == !time) {
msg $chan The time is $asctime(HH:nn:ss)
}
}
}
No doubt about that I'm the NUB...
But I think it looks cleaner maybe not the above with all the color/bold added...
But the "general" scripting style I find easier to figure out / I think looks cleaner
And what is you mean when you say redundant please give a small example ?
EDIT:
And yeah I do know the meaning of the word redundant :D :D hehe :P
iHope it isn't the setting the %CMD you mean... cause that I know... and I would just use ($strip($1) == W/E)
But I don't let people use bold or what ever for My bot cmds and again it was just if he couldn't get the ($strip($1) == W/E) to work... then the above would work...
Was just posting a other way to do it that would work
if the ($strip($1) == !time) in code 1 wasn't working for him.
Then the above would work.
And the above script is not My normal scripting style.
i use ($1 == W/E) for My commands... and/or ($1 isin %W/E)
and I normally don't use flood for My commands... only form for flood protection is SPAM ( as in repeat ) and that works for "cmds" as well if people SPAM them.
on *:TEXT:*:#: { inc -u5 $+(%,$1)
;*** SETTiNG COMMAND
set %CMD $strip($1)
;*** !TIME
if (%CMD == !time) && ($+(%,$1) <= 1) { msg # The time is $+(14,$asctime(HH:nn:ss TT),) 15[ 5TimeZone $+(14GMT,$gmt(z),) 15] }
;*** !DATE
elseif (%CMD == !date) && ($+(%,$1) <= 1) { msg # 15[ $+(14,$asctime(dddd),) 15] The $+(14,$asctime(dd),) of $+(14,$asctime(mmmm),) 15[ 5Date 15] $+(14,$asctime(mmmm),14/14,$asctime(dddd)15,/14,$asctime(yyyy),) 15[ $+(5,$asctime(mm/dd/yy),) 15] }
;*** !DAY
elseif (%CMD == !day) && ($+(%,$1) <= 1) { msg # 15[ $+(,$asctime(dddd),) 15] The $+(14,$ord($asctime(dd)),) of $+(14,$asctime(mmmm),) or is it $+(14,$asctime(mmmm),) the $+(14,$ord($asctime(dd)),) ? 14- Either way... My spider sense tells Me the time is $+(14,$asctime(HH:nn:ss TT),) }
;*** MORE COMMAND AND SO ON AND SO ON
unset %CMD
}
ooO( Took Me a while since I found fail looking for this... so was editing own stuff... but )
This is how I normally would go about if if I had to add flood
The previous script above was just a other way to show how it would work with $strip
Not something I would do normally
But I script pretty weird... no doubt about that... but I like it "clean" ???
EDIT
2 slow onces again :P
And come to think of it not quite sure I would go about it like I posted above... but will do the trick and with flooder added
if you are going to go the route of doing on :text::#:{ then move the flood control under the if ($strip($1) = !time) cuz if you don't it triggers the flood control when ever someone types anything. or do it like this whatever...
on *:text:*:#: {
if ($strip($1) = !time && !%t) {
inc -u5 %t
msg # The time here is $time(HH:nn:ss)
}
}
Code one should work ooO( Haven't tested it tho )
else you could do
on *:TEXT:*:#: {
if (%t != $null) { halt }
;* FLOOD ;* CMD
inc -u5 %t | set %CMD $strip($1)
;*** !TIME
if (%CMD == !time) { msg # The time is $time(HH:nn:ss) | unset %CMD | halt }
}
^ That will work...
EDIT
I was 2 slow :P
Hmm, Jethro_, do you mean to say that these two codes would give the same result?
Code 1:
on *:text:*:#: {
if !%t { inc -u5 %t
if ($strip($1) == !time) {
msg $chan The time is $asctime(HH:nn:ss)
}
}
}
Code 2:
on *:text:$(iif($strip($1)) == !time,$1)):#:{
if %t { inc -u5 %t
msg $chan The time is $asctime(HH:nn:ss)
}
}
Because when I use code 1, I am unable to use bolds, underlines, reverses and colors to trigger the command, however in code 2, where the $() and iif() functions are used, I am able to use everything that ($strip($1) == !time) should disable to trigger the command.
Should that be happening? :?
Thanks.
-Clayton
I may have misread what you meant. You can still have the $strip function using $iif() and $()
on *:text:$($iif($strip($1) == !time,$1)):#:{
This is the same as
if ($strip($1) == !cmd) {
except it's coded within the match text section of the event. And last but not least, you can use regex
on $*:text:/^!time$/iS:#:{
where the /S will strip out all control codes.
Wuut ?
Mash, you're incorrect.
I just did a test... and no... what I said was correct ?
When doing it like he had it before
on *:TEXT:!TIME:#:
The $strip has no function... since the above code will not activate when doing !TIME
It only has a function when doing like it is now...
like I said in first post if it was part of a ( BiGGeR ) on :TEXT::#:
ooO( like it is now... )
At least when I tried doing it with the above *on :TEXT:!TIME:#:**
with bold !TIME it didn't activate.
On a further note, you need to have a trigger control so you don't get spammed:
on *:text:*:#: {
if !%t { inc -u5 %t
if ($strip($1) == !time) {
msg $chan The time is $time(HH:nn:ss)
}
}
}
And you only need one command in the $1, repeating it in the match text section of the event is not necessary.
You can use $time() in place of the $asctime(). They give you the same result.
Yeah it works with it... as I said... it works like it suppose to ( besides from the $gmt that is :P )
Was just saying that I ain't sure that you need the $strip when you have it like above
on *:TEXT:!time:#: {
only activates if it's !time not if it's !time !time or !time so there is no need for it
But yes it works... and is the only thing that is important ;)
Not sure you need the $strip when you have it like above ^
But besides from that it works... :D
and I guess it does what it's suppose to :D
EDIT:
LoL... didn't even check that...
and no... not here anyways... it's a hour behind My time
and 5 hours ahead of My PC time.