|
Joined: Mar 2006
Posts: 10
Pikka bird
|
OP
Pikka bird
Joined: Mar 2006
Posts: 10 |
Is there a way to make a random timer?
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
You're going to have to clarify your meaning.
A basic timer consists of 3 parts. 1) The number of repetitions 2) The delay between each repetition 3) The command issued.
It's possible to randomize any one or even all of these, but the details depend on your specific requirements.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
And for the repetitions or delay, see /help $rand
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Mar 2006
Posts: 10
Pikka bird
|
OP
Pikka bird
Joined: Mar 2006
Posts: 10 |
I'm trying to get a timer to run at a random time.
Using signals I will be shutting the original timer that triggered the signal down and then starting another timer of the same name again at a random time to randomize the action.
|
|
|
|
Joined: Feb 2006
Posts: 546
Fjord artisan
|
Fjord artisan
Joined: Feb 2006
Posts: 546 |
$rand(N,M) can be used to return a random integer between N and M (inclusive). if you want to start a timer that triggers at a random time between now and, for example, 4:00PM of the current day you can use:
//timer 1 $rand(0, $calc($ctime(16:00 $date) - $ctime)) <command>
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
|
|
|
|
Joined: Mar 2006
Posts: 10
Pikka bird
|
OP
Pikka bird
Joined: Mar 2006
Posts: 10 |
I figured out how to do it. on 1:signal:start: /timer9 0 $rand(X,X) /signal go on 1:signal:go:{
/timer9 off
/msg #room message
/signal start
} Thank you all for your help.
Last edited by strac; 20/07/10 04:13 PM.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
I've always been advised to not use a numeric as a timer name, though the actual reasoning for not doing so I don't recall any longer, but it seems to me it has something to do with the fact that mIRC automatically associates a numeric with each timer that is started.
|
|
|
|
Joined: Jul 2006
Posts: 4,193
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,193 |
mIRC use an unique numeric timer name if you don't specify a name for your timer, that's it. Using a numeric name is perfectly fine and is the same as using any other name
Last edited by Wims; 20/07/10 10:48 PM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
OK. I thought that a numeric was assigned whether you specified a name or not.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
That said, RusselB is correct. You should not use a numeric timer name. mIRC will auto-generate a unique name if none is given, but if mIRC already autogenerated timer9, the above script will overwrite it, which is bad. Consider: //var %i = 1 | while (%i < 10) { /timer 1 2 echo -a %i | inc %i } | /timer9 1 1 echo -a NOT 9 You will get 1-8 and then "NOT 9" instead of 1-9 plus the *extra* NOT 9 message. And because mIRC uses numeric values as autogenerated names, numbers, especially those < 10, are most likely to be in use and not really unique. A named timer is much safer.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jul 2006
Posts: 4,193
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,193 |
Your post is completely irrelevant for me, you're basically saying that we shouldn't run a timer that already exists because it will overwrite. This is true whatever the name and the conclusion is the same in both case : you can use whatever the name you want for your new named timer but be sure this name isn't already used.
There's more chance that a timer name like 1,2,...,9 is already in use because of how mIRC automatically name a timer but it doesn't change anything at all, you should never assume that the name you're going to use isn't already used, and this either for "argv0", for "wims" or for "1", there is no "most likely" in such a case
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
I'm saying you should not use numeric values for explicit timer names because there is a very high chance that you can overwrite an auto-generated timer name. Especially for values under 10. This seems pretty clear to me. I'm not sure why any sane person would argue against this statement.
Your point that "you should never assume the name isn't in use" is a little unrealistic. It's fairly reasonable for a scripter to assume "MYSCRIPT.MYTIMERNAME" would be unique to "MYSCRIPT" and unlikely to be used by anything else in mIRC. Heck, it's reasonable to even assume /timerRANDOMTIMER would be unused. It might not be guaranteed, but we're not discussing theoretics here. Using a name like "9" is far more likely to be in use than "SOMENAME", no matter what the name is, simply because mIRC auto-generates these timers. A few days in a STATS 101 class would teach you the practical differences between the above two names. It's not "the same", not in real world scenarios.
But you're right-- all of this is irrelevant. The above snippet uses a poorly named timer-- someone should have stated this. RusselB did, and he was right in doing so. Don't defend poor scripting practices. End of story.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jul 2006
Posts: 4,193
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,193 |
I'm not defending poor scripting practice, what I said still stand : you can use any timer name, it could be anything, obviously as long as you know it won't conflict with others timers, the fact that it has more chance to conflict with small numeric name is what I call irrelevant. I didn't argue against your statement nor I said it wasn't clear, I agree with the recommendation, I would tell anyone that use '9' as a timer name to change it, just because it's impersonal. But in my opinion that's the whole problem, we should be telling people to check the name they are going to use instead of telling them to use a name that is not likely to be used, which is, you know, the bad practice.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
There really isn't a good reason to check every single timer you use to see if it's in use. In addition, some timers WILL be in use by you and you want to overwrite them. So a check to see if it's in use wouldn't help in the first place in those situations.
Yes, you *might* overwrite a named timer accidentally, but the chances are so low as to be non-existent as long as you're not naming it something like mytimer or countdown or some other name that has a decent chance of being used by someone else (not as much as a numerical timer, but it's still high enough to avoid). As long as you name it something unique that isn't likely to be used by anyone else, then you don't need to check if it's in use. That's a waste of time and effort and in some cases, as mentioned, it's not possible to easily tell the difference if you want to overwrite your own timer but not an auto-generated timer.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|