mIRC Home    About    Download    Register    News    Help

Print Thread
#108673 21/01/05 07:08 PM
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
Is there a way for me to do a $read(file.txt) and have the random outputs be both /msg and have some of them /describe. So that it randomly picks a describe or msg.

Thanks

#108674 21/01/05 07:18 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Usage: /output

alias output $iif($r(0,1),msg,describe) # $$read(file.txt)


Gone.
#108675 21/01/05 07:30 PM
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
im a n00b :tongue: Could you write out a quick example script of how to use /output

Thanks

#108676 21/01/05 07:34 PM
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
Would that make it randomly do a describe or msg? Cause what i want is for certain ones to be msg, and certain ones describe.

Thanks

#108677 21/01/05 07:40 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well,

all you specified was random, so I can't do more than that, unless you specify under what conditions you want the alias to do a msg, and what conditions to do a describe.

Right now there's a 50% chance with every call of /output that it will be msg and 50% that it will be describe.

Example? You just paste that alias into your remote, you change file.txt to whatever file you want it to be which is located in your main mirc folder, and then on a channel you type: /output

That's it.


Gone.
#108678 21/01/05 07:54 PM
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
If i divide the the file into 2 parts, is there a way to have the ones under [msg] to /msg and the ones under [desc] to /describe; but for the script to use both of them randomly.

file.txt
-----------------------------------
[msg]
hi
hello

[desc]
waves
-----------------------------------

So when someone says hi, i will sometimes /msg hi, or hello and sometimes /describe waves

Thanks

#108679 21/01/05 09:25 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
if u broke it into two files it would be easy (maybe it is the other way as well I cant think of it tho)

alias output $iif($r(0,1),msg # $$read(filemsg.txt),describe # $$read(filedesc.txt))

no [msg] or [desc] headers needed tho.

#108680 21/01/05 10:00 PM
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
Thanks for all your help. Works great

#108681 21/01/05 10:02 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Just something I whipped up, nothing special. It stores your /msg 's and /describe's in 2 seperate boxes. It is untested so come back if it doesn't help as planned.

/rand a is to message the target window with a random item from the hash table

/rand b is to send a describe to the target window with a random item from the hash table.

Hope it's this helps. smile

Code:
menu channel {
  $iif($dialog(rand),$style(7)) Msg/Describe: { dialog -dm rand rand }
}

On *:Text:*match text*:#: {
    rand $r(a,b)
}

on 1:Start: {  
  hmake message 1000 
  hmake describe 1000
  if ($isfile(msg.hsh)) {   
    hload -o message msg.hsh 
  }
  if ($isfile(desc.hsh)) {   
    hload -o describe desc.hsh 
  }
}

dialog rand {
  title "Random Msg / Describe"
  size -1 -1 154 163
  option dbu
  combo 1, 4 14 70 98, size
  combo 2, 77 14 70 98, size
  text "                   /msg                                      /describe", 3, 3 3 149 8
  button "Add", 4, 16 113 22 12
  button "Del", 5, 39 113 22 12
  button "Del", 6, 113 113 22 12
  button "Add", 7, 90 113 22 12
  button "Close", 8, 61 142 37 12
}

alias getmsg {
  if (($hget(message) && $hget(message,0).item) > 0) { 
    var %msg = $hget(message,0).item
    while (%msg) {
      if ($dialog(rand)) {
        did -a rand 1 $hget(message,%msg).data
        dec %msg
      }
    }
  }
  elseif (($hget(message) && !$hget(message,0).item)) {  return }
}

alias getdesc {
  if (($hget(describe) && $hget(describe,0).item) > 0) { 
    var %desc = $hget(describe,0).item
    while (%desc) {
      if ($dialog(rand)) {
        did -a rand 2 $hget(describe,%desc).data
        dec %desc
      }
    }
  }
  elseif (($hget(describe) && !$hget(describe,0).item)) {  return }
}

on 1:dialog:rand:init:0: {
  did -b rand 5
  did -b rand 6
  getmsg
  getdesc
}

on 1:dialog:rand:close:0: {
  hsave -o message msg.hsh
  hsave -o describe desc.hsh
}

on 1:dialog:rand:sclick:1: {
  if ($did(rand,1).sel) { 
    did -e rand 5
  }
}

on 1:dialog:rand:sclick:2: {
  if ($did(rand,2).sel) { 
    did -e rand 7
  }
}

on 1:dialog:rand:sclick:4: {
  if ($hget(message)) {
    if ($did($dname,1).text) {
      did -a rand 1 $did($dname,1).text
      hadd message $didwm(rand, 1,$did(rand,1).text) $did($dname,1).text
    }
  }
}

on 1:dialog:rand:sclick:5: {
  if ($did($dname,1).sel) {
    if ($hget(message)) {
      hdel message $didwm(rand, 1,$did(rand,1).seltext)
      did -d rand 1 $didwm(rand, 1,$did(rand,1).seltext)
      did -b rand 5 
    }
  }
}

on 1:dialog:rand:sclick:6: {
  if ($did($dname,2).sel) {
    if ($hget(describe)) {
      hdel describe $didwm(rand, 2,$did(rand,2).seltext)
      did -d rand 2 $didwm(rand, 2,$did(rand,2).seltext)
      did -b rand 6
    }
  }
}

on 1:dialog:rand:sclick:7: {
  if ($hget(describe)) {
    if ($did($dname,2).text) {
      did -a rand 2 $did($dname,2).text
      hadd describe $didwm(rand, 2,$did(rand,2).text) $did($dname,2).text
    }
  }
}

on 1:dialog:rand:close:0: {
  hsave -o describe desc.hsh
  hsave -o message msg.hsh
}

alias rand {
  if ($1 == a) { msg $target $hget(message,$r($hget(message,0).item,1)) }
  if ($1 == b) { describe $target $hget(describe,$r($hget(describe,0).item,1)) }
}

Last edited by SladeKraven; 21/01/05 10:03 PM.
#108682 21/01/05 10:47 PM
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
wow, Thats nice. Thanks. Ill give it a try

#108683 22/01/05 03:20 AM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You're welcome. grin

I'll add some comments, just to show you how we did it and that we're on the same wave length.. smile

Code:
menu channel {
  $iif($dialog(rand),$style(7)) Msg/Describe: { dialog -dm rand rand }
}

On *:Text:*match text*:#: {
  rand $r(a,b)
}

on 1:Start: {  
  [color:green];We make our tables with 1000 slots, this is where we store all our random messages.[/color]
  hmake message 1000 
  hmake describe 1000
  [color:green];Here we check if our data files exist, and if they do, we load in our data to our database (table) which we just created with hmake
  [/color]
  if ($isfile(msg.hsh)) {   
    hload -o message msg.hsh 
  }
  if ($isfile(desc.hsh)) {   
    hload -o describe desc.hsh 
  }
}
[color:green]
;This is our dialog, this is where you type in your random words.
[/color]
dialog rand {
  title "Random Msg / Describe"
  size -1 -1 154 163
  option dbu
  combo 1, 4 14 70 98, size
  combo 2, 77 14 70 98, size
  text "                   /msg                                      /describe", 3, 3 3 149 8
  button "Add", 4, 16 113 22 12
  button "Del", 5, 39 113 22 12
  button "Del", 6, 113 113 22 12
  button "Add", 7, 90 113 22 12
  button "Close", 8, 61 142 37 12
}
[color:green]
;The two aliases below is ewhat makes everything possible. Here we perform a while loop which will loop through all our items in the table and then display our random words in the dialog for you to add/delete.
[/color]
alias getmsg {
  [color:green]
  ;Here we simply check if our hash table exists and there's atleast 1 item in our hash table.
  [/color]
  if (($hget(message) && $hget(message,0).item) > 0) { 
    [color:green]
    ;We've established there's more than one item so now we're looping through all our entries.
    [/color]    var %msg = $hget(message,0).item
    while (%msg) {
      if ($dialog(rand)) {
        [color:green]
        ;We've now finished our looping, our items have now been retrieved.  We're ready to display our data in our dialog.
        [/color]
        did -a rand 1 $hget(message,%msg).data
        dec %msg
      }
    }
  }
  [color:green]
  ;This means that if there's no items to display, we halt the operation.
  [/color]
  elseif (($hget(message) && !$hget(message,0).item)) {  return 
  }
}

[color:green]
;Same as the above alias, only this is for describe, not msg.
[/color]
alias getdesc {
  if (($hget(describe) && $hget(describe,0).item) > 0) { 
    var %desc = $hget(describe,0).item
    while (%desc) {
      if ($dialog(rand)) {
        did -a rand 2 $hget(describe,%desc).data
        dec %desc
      }
    }
  }
  elseif (($hget(describe) && !$hget(describe,0).item)) {  return 
  }
}

on 1:dialog:rand:init:0: {
  [color:green]
  ;The 2 -b switches disable the "Del" button until an item in the combo box has been selected.
  [/color]
  did -b rand 5
  did -b rand 6
  [color:green]
  ;We are getting our database entries.
  [/color] 
  getmsg
  getdesc
}

[color:green]
;When we close our dialog, the databases are saved.
[/color]
on 1:dialog:rand:close:0: {
  hsave -o message msg.hsh
  hsave -o describe desc.hsh
}

[color:green]
;When a data entry has been selected in the combo box, the delete button is then enabled.
[/color]
on 1:dialog:rand:sclick:1: {
  if ($did(rand,1).sel) { 
    did -e rand 5
  }
}

[color:green]
;Same as above, only this time with combo box 2.
[/color]
on 1:dialog:rand:sclick:2: {
  if ($did(rand,2).sel) { 
    did -e rand 7
  }
}

on 1:dialog:rand:sclick:4: {
  [color:green]
  ;Again, this checks if the table exists.
  [/color]
  if ($hget(message)) {
    [color:green]
    ;It does exist, now we check if we have type in a data entry in the combo box.
    [/color]
    if ($did($dname,1).text) {
      [color:green]
      ;We did type an entry, we now add that entry to the dialog, and its written into the database.
      [/color]
      did -a rand 1 $did($dname,1).text
      hadd message $didwm(rand, 1,$did(rand,1).text) $did($dname,1).text
    }
  }
}

on 1:dialog:rand:sclick:5: {
  [color:green]
  ;This checks if we've clicked an item in the combo.
  [/color]
  if ($did($dname,1).sel) {
    [color:green]
    ;Again, this checks if the table exists.
    [/color]
    if ($hget(message)) {
      [color:green]
      ;It does exist, we're now deleting the entry from the database, and removing it from the dialog.
      [/color]
      hdel message $didwm(rand, 1,$did(rand,1).seltext)
      did -d rand 1 $didwm(rand, 1,$did(rand,1).seltext)
      [color:green]
      ;This disables our "Del" button again.
      [/color]
      did -b rand 5 
    }
  }
}

[color:green]
;Ass above only this checks for adding and deleting on the combo 2.
[/color]

on 1:dialog:rand:sclick:6: {
  if ($did($dname,2).sel) {
    if ($hget(describe)) {
      hdel describe $didwm(rand, 2,$did(rand,2).seltext)
      did -d rand 2 $didwm(rand, 2,$did(rand,2).seltext)
      did -b rand 6
    }
  }
}

on 1:dialog:rand:sclick:7: {
  if ($hget(describe)) {
    if ($did($dname,2).text) {
      did -a rand 2 $did($dname,2).text
      hadd describe $didwm(rand, 2,$did(rand,2).text) $did($dname,2).text
    }
  }
}
[color:green]
;For some stupid reason I added the close dialog event twice, it's either because I am tired, or it only took just over an hour so I kind of rush things.  So you can either remove this one or the above one.  My apologies.
[/color]
on 1:dialog:rand:close:0: {
  hsave -o describe desc.hsh
  hsave -o message msg.hsh
}

[color:green]
;Our alias for messaging, typing /rand a sends a msg to the target window with a random msg.  And /rand b sends an action to the target window with a random action
[/color]

alias rand {
  if ($1 == a) { msg $target $hget(message,$r($hget(message,0).item,1)) }
  if ($1 == b) { describe $target $hget(describe,$r($hget(describe,0).item,1)) }
}

Last edited by SladeKraven; 22/01/05 03:28 AM.

Link Copied to Clipboard