mIRC Home    About    Download    Register    News    Help

Print Thread
#224307 08/08/10 04:41 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Greetings all,

I would like to set a variable, and then want to be able to check if the variable was set more then a week ago to do something.

i.e if (%var more then a week old { execute }

Thanks in advance.


Newbie
HaleyJ #224308 08/08/10 04:51 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
No need to use $ticks for this.
Here's a quick example of how you could do this.
Code:
on me:*:join:#:{
  set $+(%,join,.,$network,.,$chan) $ctime
}
on *:text:*:#:{  check_join $chan }
on *:action:*:#:{  check_join $chan }
on *:notice:*:#:{  check_join $chan }
alias -l check_join {
  if $calc($ctime - $($+(%,join,.,$network,.,$1),2)) >= $duration(1 week) {
    .msg $1 I've now been in $1 for 1 week or more consistently.
  }
}


If this is not sufficient for you to amend for your specific purposes, reply back with more details and we'll see what we can do to help.

RusselB #224310 08/08/10 05:20 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Thanks, this is very helpful.

Can i also check if it was LESS then a week ago by amending the code to
Code:
if $calc($ctime - $($+(%,join,.,$network,.,$1),2))<= $duration(1 week
? thanks again


Newbie
HaleyJ #224311 08/08/10 05:23 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes... if you include the rest of that line. smile


Invision Support
#Invision on irc.irchighway.net
Riamus2 #224312 08/08/10 05:29 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
I think I am getting there, but still unsure.

I want to add a value to a hash table called "test" so i.e
Code:
hadd -m hashtable test $ctime


I now want an alais to test if that value in the hash table is LESS then a week old, and if it is to execute a command.

i.e
Code:
if($hget(hashtable,test) < then a week) { command 
}


Sorry for being confusing earlier, I actually need less then a week not more.

Thanks.

p.s anyway for me to test that the code is working, as I do not know $ctime values from over a week ago?

Kindest regards


Newbie
HaleyJ #224313 08/08/10 05:35 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just put in the rest of what was shown:

Code:
if($hget(hashtable,test) < $duration(1 week)) { command 
}


Originally Posted By: HaleyJ
p.s anyway for me to test that the code is working, as I do not know $ctime values from over a week ago?


$ctime always changes. To know if it's working, you need the current $ctime to be 604800 higher than what is stored in your hash table. Then, just check with your IF statement.

This is how you'd know what the difference needs to be:
//echo -a $duration(1 week)


Invision Support
#Invision on irc.irchighway.net
Riamus2 #224314 08/08/10 05:40 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Originally Posted By: Riamus2


Code:
if($hget(hashtable,test) < $duration(1 week)) { command 
}



Do i need to use $calc for that?


Newbie
Riamus2 #224316 08/08/10 05:59 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Hi all,

Thanks for all the replies so far.

I have tried playing with this, and have not succeeded in getting it to work.

I have pasted this in my mIRC window

//hadd hashtable test $ctime

//if $calc($ctime - $hget(hashtable,test) <= $duration(1 week)) { echo -a lol }
it echoes lol

but if i also do
//if $calc($ctime - $hget(hashtable,test) >= $duration(1 week)) { echo -a lol }

it still echoes lol.

?!?



Newbie
HaleyJ #224319 08/08/10 07:06 PM
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Originally Posted By: HaleyJ

//if $calc($ctime - $hget(hashtable,test) <= $duration(1 week)) { echo -a lol }

//if $calc($ctime - $hget(hashtable,test) >= $duration(1 week)) { echo -a lol }


//if $calc($ctime - $hget(hashtable,test)) <= $duration(1 week) { echo -a lol }
//if $calc($ctime - $hget(hashtable,test)) >= $duration(1 week) { echo -a lol }

Crinul #224321 08/08/10 08:02 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Thanks to all replies. Working now as intended.


Newbie
HaleyJ #224340 09/08/10 01:53 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, I didn't pay attention to what you had in the table. $calc would be needed. Sorry about that.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard