mIRC Homepage
Posted By: jaredmt im a n00b - 28/02/07 04:51 AM
ok im new with scripts. i created my own bot called SLBot and i downloaded the script called DreamBot for it.

anyways i'd like an explanation of what all the symbols mean and what all the basic codes are

ex. i know * is wildcard. but idk what wildcard means frown

here's a small script i was given:
Quote:
on 1!:JOIN:#shadowlites:{ //notice $nick hi and welcome}

maybe someone can go into detail about each and every part of that? what does each symbol mean from it? and how else can i use those symbols?

i know all basics of mIRC like /nick /ns register /bs help /cs help and all that. i just dont know anything about scripts yet.

here's another script i was givin:
Quote:
On *:text:*hi*:#:/msg $chan hello $nick smile
this one uses wildcards. please go into detail on this one too. thanks smile
Posted By: RusselB Re: im a n00b - 28/02/07 08:04 AM
Code:
on 1!:join:#shadowlites:{ //notice $nick hi and welcome }

The ! means that the message will go to everyone that joins, except for the person/client that is running the code.

The * wildcard will match any entry, including no entry
The & wildcard will match any single word
The ? wildcard will match any single character

The usage of the first * in the second code, means that it will match any user level. User levels are a bit complicated for a beginner, however, they are explained in the help file under /help user levels

If you want to learn about scripting, I strongly suggest you read through the help file. Don't worry about going through it in any particular order, as many times you'll probably read something, then jump to a 2nd topic, 3rd topic, 4th, see a reference back to the 2nd topic....and so on...many times you'll probably go back and forth reading things that are new, but reference back to stuff you've already read (and it doesn't hurt to re-read those references).
Posted By: Doqnach Re: im a n00b - 28/02/07 10:15 AM
PS: commands like /ns and such are network related commands and not bound to mIRC.
Posted By: jaredmt Re: im a n00b - 01/03/07 04:13 AM
ok i read a lot about the basics of scripts. my next goal is to try to make my bot say something when it reaches a certain time.
here's the code i attempted:
Code:
If ($time == 23:06:50) { /msg $chan time for mass }


am i wrong to use a if? cus i cant get it to work. show me a code that does what im trying to do

edit: another question. ok im using thise code:
Code:
ON *:INVITE:#:{ /join $chan }

1st question is: how would i convert that to an if script?
2nd question is: how would i make it so this ONLY works when other ppl invite me. i wanna make it so it DOESNT join on self-invite to private channels
Posted By: RusselB Re: im a n00b - 01/03/07 06:32 AM
Part of the problem with your if statement, is the time that it takes to get to it and process it..You don't show how the script is started. If you want that message to go out at the same time every day, then use a timer
Code:
on me:*:join:#:{
  .timermass 23:6:50 0 86400 .msg $chan Time for Mass
}


That will start a timer called mass when you join the channel, then at 23:06:50 every day it will display that message (presuming you are on a IRC channel at that time)

Regarding the ON INVITE, try this
Code:
on *:invite:#:{
  if $nick != $me {
    .join $chan
  }
}

Posted By: Riamus2 Re: im a n00b - 01/03/07 02:05 PM
I wouldn't suggest setting the timer to check every 24 hours. If there is any lag, you might miss that time and it won't work (I think). Better to have it check every second as per the help file...

.timerTimeCheck 3:53 0 1 Do this

As for the invite thing... why not just use mIRC's built in auto-join on invite setting? Alt-O > IRC.
Posted By: starbucks_mafia Re: im a n00b - 01/03/07 02:47 PM
Lag won't affect the timer at all. The time parameter is only used when the timer is originally set, all other occasions it'll be working off the 86400 second delay only. It's still not going to be on time though since timers are pretty inaccurate (plus timers ignore the seconds portion of the <time> parameter so the code couldn't be used as-is anyway).

Still, triggering the timer every second and having a peice of code run and fail 86399 times a day is unnecessary too.

Simple solution:
Code:
on *:join:#:if ($nick == $me) && (!$timer(mass)) .timermass 23:06 1 50 massrun

alias massrun {
  .amsg Time for Mass
  .timermass 23:06 1 50 massrun
}
Posted By: jaredmt Re: im a n00b - 03/03/07 06:19 AM
k thanks a lot smile
new question. what script would i use to specifically get the time for GMT?

i wanna have a script that would tell u GMT time after you type "!gmt"
Posted By: RusselB Re: im a n00b - 03/03/07 07:05 AM
Code:
on *:text:!gmt:#:{
.msg $chan $asctime($gmt)
}


/help $gmt
Posted By: jaredmt Re: im a n00b - 03/03/07 05:31 PM
ok cool. now how would i do !ET? cus i tried doing $time($gmt - 5) and things like that but it wouldnt work. i just wanna know how to subtract or add from a certain time
Posted By: Riamus2 Re: im a n00b - 03/03/07 07:52 PM
//echo -a $asctime($calc($gmt - (5 * 3600)))

You need to use $calc whenever you're doing a calculation. Also, because the times are based on seconds, you need to multiply it by 3600 (60 seconds in a minute, 60 minutes in an hour) to get it to be the right amount to subtract. You can just change the 5 to anything else in this and it will give you the correct time. And change the - to a + if you need to go the other way.
Posted By: jaredmt Re: im a n00b - 03/03/07 11:42 PM
o cool. Now just out of curiosity. see where i have bold?

Quote:
//echo -a $asctime($calc($gmt - (5 * 3600)))


im wondering if i could make those depend on what the person types in. example if i type !gmt + 3 i'd want to code to be
Quote:
//echo -a $asctime($calc($gmt + (3 * 3600)))


so how would i do that?
Posted By: DJ_Sol Re: im a n00b - 04/03/07 01:40 AM
if a users text = !gmt + 3

$1 == !gmt
$2 == +
$3 == 3

They are seperated by spaces.

Text = Hello my name is Travis.
$1 = Hello
$2 = my
$3 = name
$4 = Travis.

Quote:

User Text = !gmt + 3

echo -a $asctime($calc($gmt $2 ($3 * 3600)))
Posted By: jaredmt Re: im a n00b - 05/03/07 05:14 AM
ok thanks. i got it to work by responding to a text. now what i wanna do is make it so they have to type !gmt [+/-] [# of hours] and if they type too many words or if they type it wrong i want to tell them that.

i tried an if code:
Quote:
ON *:TEXT:!gmt *:#:{ if ($text == !gmt $2 $3) { /notice $nick GMT $2 $3 = $time($calc($gmt $2 ($3 * 3600))) }
else { /notice $nick Sorry $nick, you have typed an incorrect code frown }
}



but it wouldnt work. i have questions for the parts in bold.
for the first part: i have !gmt *. i only put the * there like that cus im a noob. What i really want the code to respond to is three words and the first word being !gmt and the other two words being anything. what symbol would i use for any word?

for the second bold part: i have tried the same but it didnt work. I want to replace $2 with a symbol that only responds to + or - and i want to replace $3 with a symbol that only responds to a number. how would i do that?
Posted By: RusselB Re: im a n00b - 05/03/07 05:27 AM
First off, there's no $text identifier in mIRC. Secondly, your usage of the $time identifier is incorrect.
Code:
on *:text:!gmt & &:#:{
  if !$istok(+ -,$2,32) || $3 !isnum 0-12 {
    .notice $nick Sorry $nick $+ $chr(44) You have typed an incorrect code :(
    .notice $nick Usage is !gmt + <number of hours> or !gmt - <number of hours>
  }
  else {
    .notice $nick GMT $2- = $asctime($calc($gmt $2 ($3 * 3600)))
  }
}


Here's an explanation of my code:
The first line is the ON TEXT event, which requires !gmt to be the first item.
The 2nd & 3rd items are represented by the & wildcard, which matches any single 'word'. In this case, 'word' is defined as the number of characters between two spaces.
In the 2nd line, I check to ensure that the 2nd item is either a + or - symbol (don't want to get an * or / in there, or the math would still work, but you could get one heck of a weird number).
Next, in the 2nd line, I ensure that the 3rd item is a number, and I included a range of 0 to 12, so that they can't enter a number of 13 hours (for example).

If you don't like the format of the date/time that is provided with the default format of $asctime, then you should read up on the proper formats that are available for that identifier.
/help $asctime

Posted By: jaredmt Re: im a n00b - 07/03/07 07:16 AM
o interesting. i learned a lot from all those new things i never saw before but now i got new questions lol

1. what is the difference between using "." and using { } ?

2. after researching and goin on #help i understand this: $istok(text,token,C)

...and C is the hexidecimal for 12. but accourding to http://www.mirc.net/ascii.php 12 is a block symbol. i can assume that 12 is suppoesed to be a symbol for separator and i only know that from the example you gave me. where can i find a better ASCII chart that shows all the examples and what they mean?

3. k using $istok(text,token,C) the last part is asking for a separator in the first part? therefore you used space separator for "(+ -" right? or was it space separator for the text being typed by the person triggering the code?
Posted By: RusselB Re: im a n00b - 07/03/07 08:45 AM
1) These two items are completely different and have little relevance to each other.
Using . (ie: .notice) is the same thing as using /notice, except for the fact that the . makes the command silent (handy if you're making a bot with a lot of commands that don't have to show on the bot's screen)

The usage of the braces { } allows mutliple lines of commands for a single event or condition.

2) I don't understand where you're getting the 12 from as the C character (actually called the token delimiter), as I used 32 (which is the space character).

3) Your first idea is correct. It has little to do with what the person triggering the code types. As long as they type + (or -) as the second item (space separated) in the line, then the code functions.

Items typed in are always presumed to be space separated for most mIRC codes that use entries, as it is the easiest method.
I have written codes that allow people to enter multiple items using commas and/or spaces, but most people (when typing) use the space bar between words automatically.
Posted By: Riamus2 Re: im a n00b - 07/03/07 02:15 PM
And to find out what number to put in place of C in $istok(text,token,C), you can always just use:

//echo -a $asc(.)
//echo -a $asc(-)

Etc. (typed from the edit line). That will give you the numerical value for the character you're entering. Note that not all characters can be found using this method (such as a comma) due to mIRC's evaluation methods. A comma is 44, however.
Posted By: genius_at_work Re: im a n00b - 07/03/07 03:20 PM
Just to clarify, in token identifiers, the 'C' (as in algebra) represents a numerical value of your choosing (the fact that a C is used is irrelevent). The value is in decimal form, not hexadecimal or any other form.

If you had a string like this: abc.def.ghi you could 'delimit' (split) it using any of the characters (a,b,c,.,etc). The most logical character to use in this example is the . as it gives you 3 useful chunks of text. Since the token must be a numerical value, the . must be converted to its decimal ascii equivalent. As shown before, you can use the $asc identifier to get the value, or you could google 'ascii chart' to get a full listing. In a typical sentence, the space character (32 decimal) is used as the delimiter because it results in all the characters being split into the actual words that are being said.

-genius_at_work
© mIRC Discussion Forums