mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 79
A
Ancyker Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Feb 2003
Posts: 79
OK well, heres how it is. I have this text file with the "monsters" in a game I play. I want the users in IRC to be able to do like !monster monster_name/id and get info about it. I already know how to process the string of data, what I do not know is how to fish it out of the text file. Heres an example line in the file...

1002,PORING,Poring,1,50..............................

the only important part is the first number (unique to the monster) and the name (a few are repeated), if they know the ID it would be simple. I would just subtract 1001 from it and read that line, the problem is not everyone has easy access to that information (theyd need this file, and if they had it, they wouldnt need the script), I know i can use tokens to read it, but im just having the problem with finding it in the file.

I thought of having a reverse text file, where the ID was second and the monster first, that way i could check each line for the mob name, but them mIRC eats CPU like crazy and lags the computer and therefore the server...which is a problem... any ideas besides setting the mIRC cpu priority to low? (dont have XP)

Joined: Dec 2002
Posts: 124
B
Vogon poet
Offline
Vogon poet
B
Joined: Dec 2002
Posts: 124
let me get this straight, if someone says !monster 1002
it should return PORING?

Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Code:
/*
!monster monster_name/id
monster.txt must be like..
1002,PORING,Poring,1,50
1003,ZORRO,Zorro,1,51
1023,MAMBO,Mambo,1,51
ex of ussing.. !monster 1002 or !monster Zorro
monster_name is case insensitively
*/
on 1:TEXT:!monster *:#:{
  var %f = monsters.txt
  if ($2 isnum) { | ;User try to get info using the id
    var %Data = $read(%f,w,$+($2,$chr(44),*) ) | ; $asc(,) = 44
    msg $chan $nick %Data
  }
  elseif ($len($2) >= 1)  {
    close -@ @@
    window -h @@
    var %RegEx = /\d+\x2c(?i) $+ $2 $+ \x2c/ | ; \x2c = $asc(,) in hexadecimal
    filter -fwg %f @@ %RegEx
    var %Data = $line(@@,1)
    window -c @@
    msg $chan $nick %Data
  }
}

That code is not very fast.. If you whant a realy fast work.. You must put all the data into a hash table.. Or a window.. How many lines have you file ? If you have a lot of data.. You must have some RAM for that..


mIRC Chm Help 6.16.0.3 Full Anchored!
Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Other version what load the data into a hidden window and after search the data from it.. That version must be much faster than previous..

Code:
on 1:TEXT:!monster *:#:{
  if (!$window(@MonsterData)) {
    window -h @MonsterData
    loadbuf @MonsterData monsters.txt
  }
  if ($2 isnum) { 
    close -@ @@
    window -h @@
    filter -ww @MonsterData @@ $+($2,$chr(44),*)
    var %Data = $line(@@,1)
    window -c @@
    msg $chan $nick %Data
  }
  elseif ($len($2) >= 1)  {
    close -@ @@
    window -h @@
    var %RegEx = /\d+\x2c(?i) $+ $2 $+ \x2c/ | ; \x2c = $asc(,) in hexadecimal
    filter -wwg @MonsterData @@ %RegEx
    var %Data = $line(@@,1)
    window -c @@
    msg $chan $nick %Data
  }
}


mIRC Chm Help 6.16.0.3 Full Anchored!
Joined: Feb 2003
Posts: 79
A
Ancyker Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Feb 2003
Posts: 79
.:16:47:40.Ancyker:. ~totalmonsters
.:16:47:40.aROBot`:. 998
.:16:46:40.Ancyker:. ~totalitems
.:16:46:40.aROBot`:. 1475

what would be an easy way to convert thte text databases into hash tables?

Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Imho in your case best is to use a Hidden Window..
Is my 2-th example slow ?


mIRC Chm Help 6.16.0.3 Full Anchored!

Link Copied to Clipboard