mIRC Homepage
Posted By: Mike512 Add onto .txt lines - 20/06/15 01:45 AM
Hey I hope some one can help I've looked a lot of places for an answer and can't seem to find one that works. I would like to make a script that builds up some responses, then posts them in one msg to the channel every 10 sec. Here is what I have so far:
Code:
on *:text:!vp:#: {
     write -a vplookup.txt  $nick has $readini(gold.ini,$ (#,.,$nick),Points) Victory Points! |
     if (%vplook = 1) { return }
     .timer 0 10 vpcheck
     set %vplook 1
}

alias -l vpcheck {
msg #channel $read(vplookup.txt)
set %vplook 0
write -c vplookup.txt
return
}


This works for collecting the points outputs but post them to separate lines so I just get a random one out in the end. I would like it to post all to one line so its all in one msg. Thanks for taking the time to help guys!
Posted By: Mike512 Re: Add onto .txt lines - 20/06/15 04:59 AM
I have been playing around with it and I have got it to work. Still wondering if there is a better way to do it but here is what i got.
Code:
on *:text:!vp:#:{
       if (%x = 4) {
      set %e $nick has $readini(gold.ini,$+(#,.,$nick),Points) Victory Points! |
      inc %x
      set %vplook 0
      vpcheck $chan
        }
       if (%x = 3) {
      set %d $nick has $readini(gold.ini,$+(#,.,$nick),Points) Victory Points! |
      inc %x
        }
       if (%x = 2) {
      set %c $nick has $readini(gold.ini,$+(#,.,$nick),Points) Victory Points! |
      inc %x
        }
       if (%x = 1) {
      set %b $nick has $readini(gold.ini,$+(#,.,$nick),Points) Victory Points! |
      inc %x
        }
       if (%x = 0) {
      set %a $nick has $readini(gold.ini,$+(#,.,$nick),Points) Victory Points! |
      inc %x
        }
     write vplookup.txt %a $+ %b $+ %c $+ %d $+ %e
    if (%vplook = 1) { return }
    timer1 1 10 vpcheck $chan
     set %vplook 1
}

alias -l vpcheck {
msg $1 $read(vplookup.txt)
set %vplook 0
set %a
set %b
set %c
set %d
set %e
set %x 0
write -c vplookup.txt
return
}
Posted By: splinny Re: Add onto .txt lines - 20/06/15 06:48 AM
1. You can use ONE var to store whole reply, like " set %x %x %user with %user_points"
2. You can use "set -u10 %checker" for:
2.1 if %x is empty - you set %x with new reply and set -u %checker
2.2 if %x is not empty and %checker exists - add new reply to %x (see 1.)
2.3 if %x is not empty and %checker do not exist (expired after -u secs) - post %x to channel and set %x $null.
Posted By: Mike512 Re: Add onto .txt lines - 20/06/15 05:54 PM
Thanks. Just a few questions. Im not sure how to add more info into an existing var.

And if I use set -u10 %checker then it wont post till another command comes in and it checks for %x is not empty and %checker does not exist. I think timer is still my best bet on that.

I want it to once the first command comes in wait 10s to see if anyone else is going to use the same command and then post all of the to a single msg. if only one person posts the command then I still want it to trigger.
Posted By: splinny Re: Add onto .txt lines - 20/06/15 06:03 PM
Add /timer to 2.1, and about adding something to existing %var - see 1.
Posted By: Mike512 Re: Add onto .txt lines - 21/06/15 12:06 AM
thanks thats works great so simple. here is the code i have now just to make sure but it seems to work fine.

Code:
on *:text:!vp:#:{
if ($($+(%,floodvp.,$nick),2)) { return }
 set %user_points $nick has $readini(gold.ini,$+(#,.,$nick),Points) Victory Points! |
 set %x %x %user_points
 set -u30 %floodvp. $+ $nick On
    if (%vplook = 1) { return }
    timer1 1 10 vpcheck $chan
     set %vplook 1
}

alias -l vpcheck {
msg $1 %x
set %x
set %vplook
return
}
Posted By: splinny Re: Add onto .txt lines - 21/06/15 12:44 AM
Code:
if (%vplook = 1) { return }

should be
Code:
if (%vplook == 1) { return }

Looks not perfect, but should work as you wanted.
Posted By: Loki12583 Re: Add onto .txt lines - 21/06/15 01:35 AM
A single = is a valid comparison
Posted By: splinny Re: Add onto .txt lines - 21/06/15 05:06 AM
Hm, is it a "new" (less then 10 years) change or was it always (10+ years ago) working?:)
© mIRC Discussion Forums