Simple Time Script

By Clayton on Dec 29, 2010

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)
    }
  }
}

Comments

Sign in to comment.
Jethro   -  Mar 21, 2011

skipper5, try changing > $asctime(HH:nn:ss)to

$time($calc($gmt -5*3600),hh:nn:ss TT)
 Respond  
skiper5   -  Mar 20, 2011

how would you modify this script so that instead of showing the current time it shows two hours ahead? example, if current time is 10 pm , it will show 12am . can it be done?

 Respond  
MashhitDK   -  Dec 29, 2010

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...

 Respond  
Jethro   -  Dec 29, 2010

I'm sorry to say that your script doesn't look that clean...and you don't script weirdly but redundantly.

 Respond  
MashhitDK   -  Dec 29, 2010

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

 Respond  
napa182   -  Dec 29, 2010

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)
  }
}
 Respond  
Jethro   -  Dec 29, 2010

Mash,

Why: if (%t != $null) { halt }
when you simply do: if (!%t) {

don't use /halt unnecessarily.

Why set a global variable for $1 and then gets it unset? Thev variable is not needed.

Don't script with redundancy.

 Respond  
MashhitDK   -  Dec 29, 2010

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...

  • But code 1 should also work if you ask Me... ooO( But then again... I am then NUB )

EDIT
I was 2 slow :P

 Respond  
Jethro   -  Dec 29, 2010

You missed a dollar sign:> on *:text:$($iif($strip($1) == !time,$1)):#:{and yes, they work the same way. Also, the %t has to have the ! affixed to it to be negated.

if !%t {Or else the code will never activate.

You also had an extra parenthesis in the $strip($1)

 Respond  
Clayton   -  Dec 29, 2010

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

 Respond  
Jethro   -  Dec 29, 2010

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.

 Respond  
MashhitDK   -  Dec 29, 2010

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.

 Respond  
Clayton   -  Dec 29, 2010

Ahh thanks Jethro_ wasn't sure how to code a trigger control..

I changed the code to $1 in my remotes but forgot about this snippet.

In this instance, wouldn't the $time() and $asctime() be a matter of preference? Seeing as they both give the same result that is.

Thanks.

-Clayton

 Respond  
Jethro   -  Dec 29, 2010

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.

 Respond  
Jethro   -  Dec 29, 2010

Mash, you're incorrect. If Clayton's mIRC wasn't set for the incoming messages to be stripped of control codes, the commad !time with color, underline, italic and bold char would't be recognized. Using $strip() ensures that all control codes get stripped.

 Respond  
MashhitDK   -  Dec 29, 2010

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 ;)

 Respond  
Clayton   -  Dec 29, 2010

Thanks Jethro_ - I can see your point. $gmt is not needed.

@MashhitDK - I think that this script would work with and without the $strip here, possibly a matter of preference.

Thanks for the advice though.

-Clayton

 Respond  
MashhitDK   -  Dec 29, 2010

Not sure you need the $strip when you have it like above ^

  • But ain't sure ooO( I'm the NUB )
    I wouldn't have used it Myself unless it was a part of a BiGGeR on :TEXT::#: event.

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.

 Respond  
Jethro   -  Dec 29, 2010

Well, using $gmt may not give people the actual time of where you're located.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.