Using a hash table..:)
Code:
on *:text:!fact:#usa:{
  [color:green]; Check if %facts variable exists; return if it does[/color]
  if %fact { return }
  [color:green]; Check if table exists and has data in it[/color]
  [color:green]; If not create/populate the table[/color]
  if !$hget(facts,0).item {
    [color:green]; Filter any possible blank lines out of file[/color]
    [color:green]; (You can remove this if it is unneeded)[/color]
    filter -cff facts.txt facts.txt *?*
    [color:green]; If no facts are available, return[/color]
    [color:blue]; If you remove the "/filter ..." line from above, remove this next one also.[/color]
    if !$filtered { return }
    [color:green]; Make the table if needs be[/color]
    if !$hget(facts) { .hmake facts 50 }
    [color:green]; Load the data into table[/color]
    hload -n facts facts.txt
  }
  [color:green]; grab a fact; msg it to channel[/color]
  var %a = $hfind(facts,*,1,w)
  msg #usa $hget(facts,%a)
  [color:green]; Delete this item from table[/color]
  hdel facts %a
  [color:green]; Create %facts for 30 seconds (flood prevention).[/color]
  inc -u30 %fact
}
"/hload -n" lets you use an ordinary text file, ""You can use -n to load or save files as data only, with no items. When loading with -n each line of data is assigned an N item value, starting at N = 1""

Edited: added the blue line

Last edited by Iori; 20/09/03 08:01 AM.