mIRC Home    About    Download    Register    News    Help

Print Thread
#200157 29/05/08 12:02 PM
Joined: Sep 2006
Posts: 35
C
chump Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Sep 2006
Posts: 35
hi guys iam trying to make a lil search script that goes somthing like this it consists on 2 ontexts


on *:TEXT:!adddvdr *:#test:{
if (($nick == $nick)) && ((bot == $me)) {
if ($read(dvdr.txt,w,$2-)) {
msg #test This already exists!
}
else {
write dvdr.txt $2-
msg #test This has been successfully added.
}
}
}
on *:TEXT:!deldvdr *:#test:{
if (($nick == $nick)) && ((bot == $me)) {
if (!$read(dvdr.txt,w,$2-)) {
msg #test This doesn't exist!
}
else {
write -dl $readn dvdr.txt
msg #test Has been successfully deleted.
}
}


the above works great,but what id like to try and do is make it so i dont have to have multi scripts of the above for each txt file..since it has to be able to read from around 12 txt files

and using diff triggers such as !addxvid !addgames etc any help gladly welcomed cheers guys smile

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
well if your telling me your code works... ill just edit it so that any !add or !del command is changed into a text format so you don't need to make 1 million on text events

Just to let you know what I did is store a temp var with the data located in $1 ""!addxxxx"" then i strip !add out of it and the end result is the name

Code:
on *:TEXT:*:#test:{
  if (!add isin $1) && (($nick == $nick)) && ((bot == $me)) {
    var %x = $remove($1,$left($1,-4))
    if ($read($+(%x,.txt),nw,$2-)) {
      msg #test This already exists!
    }
    else {
      write $+(%x,.txt) $2-
      msg #test This has been successfully added.
    }
  }
  elseif (!del isin $1) && (($nick == $nick)) && ((bot == $me)) {
    var %x = $remove($1,$left($1,-4))
    if (!$read($+(%x,.txt),nw,$2-)) {
      msg #test This doesn't exist!
    }
    else {
      write -dl $readn $+(%x,.txt)
      msg #test Has been successfully deleted.
    }
  } 
}


P.S. if this edited script dont work means your original doesn't work and how and why? It's probably because your search method for the $read event. I would use $read(file.txt,w,$+(*,blah,*)) has I don't know if it's reuqired but I always had wildcard matches in my scripts using the w switch in the $read event


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Sep 2006
Posts: 35
C
chump Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Sep 2006
Posts: 35
hi thx for speedy reply..but it dosnt appear to work frown
il try to explain it better
i have about 10 diff txt files
names like dvdr.txt xvid.txt etc

so its trying to get it to read write to the correct txt file on the call..this is the part i cannot do with out having 10 or so seperate scripts running which is a complete pain


oringinal works great btw..just a complete pain to edit each one to the diff txts files

Last edited by chump; 29/05/08 03:00 PM.
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
How are you using the trigger because in your script your checking if bot == $me but that would check if you were called bot and in a on text event it doesnt trigger you has the $me

I would change both occurange to like nickname == $nick and leave it as is

Code:
on *:TEXT:*:#test:{
  if (!add isin $1) {
    var %x = $remove($1,$left($1,-4))
    if ($read($+(%x,.txt),nw,$2-)) {
      msg #test This already exists!
    }
    else {
      write $+(%x,.txt) $2-
      msg #test This has been successfully added.
    }
  }
  elseif (!del isin $1) {
    var %x = $remove($1,$left($1,-4))
    if (!$read($+(%x,.txt),nw,$2-)) {
      msg #test This doesn't exist!
    }
    else {
      write -dl $readn $+(%x,.txt)
      msg #test Has been successfully deleted.
    }
  } 
}


try that too see smile


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
[11:08] <idletop> !adddvdr hi
[11:08] [@Elderado] This already exists!
-
[11:08] <idletop> !adddvdr hi there
[11:08] [@Elderado] This has been successfully added.
-
[11:09] <idletop> !deldvdr hi
[11:09] [@Elderado] Has been successfully deleted.
-


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Sep 2006
Posts: 35
C
chump Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Sep 2006
Posts: 35
hi again ok i seem to having it working smile but with a small problem,i have two dvdr txt files in same dir one called dvdr.txt and the other called xtdvdr.txt so i tryed !addxtdvdr test but it wrote it to dvdr.txt file instead of xtdvdr.txt any ideas?

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
my bad sorry its $left(data,+4) not -4

so...

Code:
on *:TEXT:*:#test:{
  if (!add isin $1) {
    var %x = $remove($1,$left($1,+4))
    if ($read($+(%x,.txt),nw,$2-)) {
      msg #test This already exists!
    }
    else {
      write $+(%x,.txt) $2-
      msg #test This has been successfully added.
    }
  }
  elseif (!del isin $1) {
    var %x = $remove($1,$left($1,+4))
    if (!$read($+(%x,.txt),nw,$2-)) {
      msg #test This doesn't exist!
    }
    else {
      write -dl $readn $+(%x,.txt)
      msg #test Has been successfully deleted.
    }
  } 
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Sep 2006
Posts: 35
C
chump Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Sep 2006
Posts: 35
smile works perfect ty..1 more quick question..as i have diff ontexts running with in same script(nothing to do with what we just discussed) i use alot of %vars now what i woild like to do is use %set but unset them so the same set of %set can be called by another script is that possible just by using unset %whatever
so its set and unset each time in that paticular script?

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
You could use simply
var's which sets them locally then once finish it empty's it or

/set -u300 %thisvar blah blah

will unset in 5 minutes

or everytime you use /set %var data you can use it like this

/set %this.ex data
/set %this.ap data
/set %this.fp data

/unset %this.* <=== this removes all %this. variables


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Link Copied to Clipboard