mIRC Home    About    Download    Register    News    Help

Print Thread
W
whatsthedillio
whatsthedillio
W
can someone please help me with this:
_____________________________________________________________________
Fistly i need to write the info:
i dont want it to write when anyone notices it:
on *:notice:*:?: {
if (x isin $1-) && (# isin $1-)
write info.txt $nick $strip($1) * $strip($2) * $strip($3) * $strip($4)
notify $nick
}
}


the thing is it wont reconise the # in $1- becuse # is bold!
can you help me with that?
_____________________________________________________________________
Secondly
i have written the textfile with * in between
so is it possible to find out the info with $read between these charecters
as id like for it to display
example:
name: before 1st *
time: text befor 2nd *
date: text before 3rd *
info: text before 4th *

and so on
so when people type !info $2
it will scan the txt for $2 and gather the info
please help with this if you know what i mean
thanks alot
laugh

Last edited by whatsthedillio; 20/08/04 11:45 AM.
C
Coolkill
Coolkill
C
Using, $gettok, or /tokenize You can get the n'th item. i.e. the string;

Word1*Word2*Word3*Word4

/tokenize 42 Word1*Word2*Word3*Word4
$1 now becomes, word1, $2 becomes word2 and so on.

and, $gettok.

$gettok(Word1*Word2*Word3*Word,1,42)
= Word1
$gettok(Word1*Word2*Word3*Word,2,42) = Word2
and so on..
[/color]

Note, '42' is the ascii character for *

Eamonn.


W
whatsthedillio
whatsthedillio
W
thanks for that
but will this work for more than 1 person writing $1 $2 $3 and so on
??
i mean will it work like $read(bla.txt,s, $2)$gettok(Word1*Word2*Word3*Word,1,42)
thanks alot

Last edited by whatsthedillio; 20/08/04 01:00 PM.
Z
Zyzzyx26
Zyzzyx26
Z
the thing is it wont reconise the # in $1- becuse # is bold!

If the # is there with the same purpose as $chan, it wont work, since a notice doesn't have to do with any channels. In other words, there is no "channel" in a notice event. You can try, if you want to, a while loop with $comchan:
Code:
[color:green] ; Here is just the while loop, not the whole script.[/color]
 var %i = $comchan($nick,0)
 while (%i) {
   if ($comchan($nick,%i) isin $1-) { commands }
   dec%i
  }
I hope this helps smile

W
whatsthedillio
whatsthedillio
W
no the # is what is messaged to me
"#1"
but thatnks alot though
laugh
i dont really understand how to use $gettok
in $read i used the /tokenize
but i need to read the txt file ( a random line )
then use $gettok to separate the answers
i tried
$read(questions.txt(gettok($gettok(word1*word2**word3*word4,1,42))
but that wont work and i have no idea pls help
thanks alot

Last edited by whatsthedillio; 20/08/04 03:17 PM.
Joined: Feb 2004
Posts: 2,014
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,014
# is $chr(35) or $(#,)

Greets

Z
Zyzzyx26
Zyzzyx26
Z
There is a missing { and * in this code ( I think):
Code:
on *:NOTICE:*:?: {
 if (x isin $1-) && ($chr(35) isin $1-) [color:blue]{[/color]
  write info.txt $nick [color:blue]*[/color] $strip($1) * $strip($2) * $strip($3) * $strip($4)
  notify $nick
 }
}


To read:
Code:
on *:TEXT:!info*:#: {
[color:green]; Picks a random line[/color]
var %read = $read(info.txt)
[color:green]; Sets the variables[/color]
var %name = $gettok(%read,1,42)
var %time = $gettok(%read,2,42)
var %date = $gettok(%read,3,42)
var %info = $gettok(%read,4,42)
other commands...


OR you can use:
Code:
on *:TEXT:!info*:#: {
[color:green]; Picks a random line[/color]
var %read = $read(info.txt)
tokenize 42 %read
[color:green]; From now up to the end of the script, $1 is name, $2 is time
; $3 is date and $4 is info[/color]
other commands...
I hope this helps wink

Last edited by Zyzzyx26; 20/08/04 03:57 PM.
Joined: Feb 2004
Posts: 2,014
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,014
Quote:
i have written the textfile with * in between
so is it possible to find out the info with $read between these charecters
as id like for it to display
example:
name: before 1st *
time: text befor 2nd *
date: text before 3rd *
info: text before 4th *
and so on
so when people type !info $2
it will scan the txt for $2 and gather the info


Code:
  
on *:TEXT:!info *:#:{
  if $read(info.txt,s,$$2*) { 
    tokenize 42 $2* $+ $v1 
    msg # Name: $1 - Time: $2 - Date: $3 - Info: $4
  }
}

Greets

@Zyzzy: that would read a random line from the file, while he wants to find a specific user's info

Last edited by FiberOPtics; 20/08/04 04:11 PM.
W
whatsthedillio
whatsthedillio
W
cool,
thank you all very much
works great
laugh

Z
Zyzzyx26
Zyzzyx26
Z
I thought about it too. In their 1st post they said to scan a line, but in their 2nd there they wanted a random line.. so I chose to use the 2nd post as a refence smile

- it will scan the txt for $2 and gather the info
- but i need to read the txt file ( a random line )

Btw, in your code... why is there a * in the $2? -> $2*


Joined: Feb 2004
Posts: 2,014
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,014
Hi,


//tokenize 42 one two*three*four
-> $1 = one two

//tokenize 42 one*two*three*four
-> $1 = one

//tokenize 32 one two three | tokenize 42 $3 this*is*a*test
--> $1 = three this

//tokenize 32 one two three | tokenize 42 $3*this*is*a*test
--> $1 = three

So I added the asterisk after $2 so that the new $1 parameter would only be filled with the person we looked up.

Btw since I used the $read with s flag, it will scan the text file for a line beginning with nickname* and it will return anything that comes after that line. In his script it will return: time*date*info. That's why I added the person* ($2*) from !info <person> and tokenize it all together.


Cya later!

Last edited by FiberOPtics; 20/08/04 05:31 PM.
Z
Zyzzyx26
Zyzzyx26
Z
Oh, I didnt know you do that smile I thought I'd have to add the $+ between them. Thanks!

Joined: Feb 2004
Posts: 2,014
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,014
You're welcome,

Cya


Link Copied to Clipboard