mIRC Homepage
Posted By: Remo Why is this not working? - 31/01/05 02:46 AM
I have a hash table that has numbers as items and nicknames as data, the hash table is called helpreqs. Its a quite short help query script to make "turns" for people in a channel. theres also another hash tables where I have the helpers, there the items are nicknames and the data is a 1 only to check if it exists.
The problem is that I created a command that should read a query window and if the messager is in the helpers list it should voice the next N data items in 'helpreqs' and sort the hash table.

Should work like this: pnn N , where N is the number of people to voice.

Heres the code:

Code:
on 1:TEXT:*:?:{
  if ( hlogin == $1 ) { 
    if ( $2 == %helperpass) {
      hadd -sm helpers $nick 1
      msg $nick Helper $nick added succesfully
      halt
    }
  }
}


on 1:TEXT:*:?:
if ( pnn isin $1 ) {
  var %hnum = $2
  if ( $hfind(helpers,$nick).data !== $null) {
    var %i = 1
    while (%i <= %hnum) {
      mode #newbiehelp +m $hfind(helpreqs,%i).data
      inc %i
    }
    var %i = 1
    while (%i <= $hget(helpreqs,0).item ) {
      hadd -s helpreqs %i $hfind(helpreqs,(%i + 1)).data
      hdel -s helpreqs (%i + 1)
      inc %i
    }
  }
}



Anyone has an idea why this is not working?
Thanks

[EDIT]
The main problem is that it wont add anything to the helpers table. Im not sure why isnt it reading the query.

Well maybe im missing some information so you can understand how I tried to work this.

Code for when people joins
Code:
on *:join:#newbiehelp:
if ($hfind(helpreqs,$nick).data !== $null) {}
else { 
  /hadd -ms helpreqs ( $hget(helpreqs,0).item + 1) $nick
  /echo -st $nick added to list
}
Posted By: ricky_knuckles Re: Why is this not working? - 31/01/05 03:30 AM
on *:join:#newbiehelp:{
if ($hfind(helpreqs, $nick)) {}
else {
/hadd -ms helpreqs $calc($hget(helpreqs,0).item + 1) $nick
/echo -st $nick added to list
}
}
you could try this^
i dunno theres a tutorial at mirc.net that might you
and theres the help file 2
good luck
hopes this helps
Posted By: Remo Re: Why is this not working? - 31/01/05 03:50 AM
Thanks for the info. It didnt solve the problem but im now checking mirc.net .
Tried the help file. No answer there heheh.
It doesnt send me an error. It just doesnt read the query nor add a helper to the hash table. I belive all the other stuff works.
Posted By: DaveC Re: Why is this not working? - 31/01/05 04:47 AM
The problem is u cant have 2 TEXT events that are on the same matchtext in the same remote file, only the first one well trip.

Oh also the second one has no opening {
Posted By: Remo Re: Why is this not working? - 31/01/05 04:58 AM
It doesnt read the first one.
And thanks for the bracket advice. missed it.

[edit]Typo :S[/edit]
[edit]
Do I need a bracket in the 2nd one if I have an If command eating all that code?
--
Also tried to put all the code in one on text. Had no luck. Its not reading the first one.[/Edit]
Posted By: Remo Re: Why is this not working? - 31/01/05 05:43 AM
ok so the code now looks like:
Code:
on 1:TEXT:*:?:{
  if ( hlogin == $1 ) { 
    if ( $2 == %helperpass) {
      hadd -sm helpers $nick 1
      msg $nick Helper $nick added succesfully
      halt
    }
  }
  if ( pnn isin $1 ) {
    var %hnum = $2
    if ( $hfind(helpers,$nick).data !== $null) {
      var %i = 1
      while (%i <= %hnum) {
        mode #newbiehelp +m $hfind(helpreqs,%i).data
        inc %i
      }
      var %i = 1
      while (%i <= $hget(helpreqs,0).item ) {
        hadd -s helpreqs %i $hfind(helpreqs,(%i + 1)).data
        hdel -s helpreqs (%i + 1)
        inc %i
      }
    }
    halt
  }
}


Why doesnt this work?

[EDIT] Just tested and this code wont work neither frown
Code:
on *:join:#newbiehelp:{
if ($hfind(helpreqs, $nick)) {}
else {
/hadd -ms helpreqs $calc($hget(helpreqs,0).item + 1) $nick
/echo -st $nick added to list
}
}

[/EDIT]
Posted By: ricky_knuckles Re: Why is this not working? - 31/01/05 05:52 AM
you know you have to put something in the {}
i used halt for testing

and hmm granted i dont know much
but
Code:
  
on 1:TEXT:*:?:{
  if ( hlogin == $1 ) { 
    if ( $2 == %helperpass) {
      hadd -sm helpers $nick 1
      msg $nick Helper $nick added succesfully
      halt
    }
  }
  if ( pnn isin $1 ) {
    var %hnum = $2
    if ( $hfind(helpers,$nick).data !== $null) {
      var %i = 1
      while (%i <= %hnum) {
        mode #newbiehelp +m $hfind(helpreqs,%i).data
        inc %i
      }
      var %i = 1
      while (%i <= $hget(helpreqs,0).item ) {
        hadd -s helpreqs %i $hfind(helpreqs,(%i + 1)).data
        hdel -s helpreqs (%i + 1)
        inc %i
      }
    }
Posted By: Remo Re: Why is this not working? - 31/01/05 06:03 AM
Its like that now and its still not working frown.
the on join event is not working neither frown.
I have no idea whats wrong and Im about to shoot myself frown.
Posted By: Iori Re: Why is this not working? - 31/01/05 06:24 AM
Well one thing is mIRC won't do on-the-fly calcing like this
  • hadd -s helpreqs %i $hfind(helpreqs,(%i + 1)).data
    hdel -s helpreqs (%i + 1)


Try $calc()
  • hadd -s helpreqs %i $hfind(helpreqs,$calc(%i + 1)).data
    hdel -s helpreqs $calc(%i + 1)
Posted By: Remo Re: Why is this not working? - 31/01/05 06:33 AM
gotcha. Changed that.
I bet that works now but havent been able to make the login work:
Code:
on 1:TEXT:*:?:{
  if ( hlogin == $1 ) { 
    if ( $2 == %helperpass) {
      hadd -sm helpers $nick 1
      msg $nick Helper $nick added succesfully
      halt
    }
  }
.....
}

nor the on join code works:
Code:
on 1:join:#newbiehelp:
if ($hfind(helpreqs,$nick).data !== $null) { halt }
else { 
  /hadd -ms helpreqs $calc($hget(helpreqs,0).item + 1) $nick
  /echo -st $nick added to list
}
Posted By: Iori Re: Why is this not working? - 31/01/05 06:48 AM
The join is still missing braces...
Code:
on 1:join:#newbiehelp:[color:red]{[/color]
  if (!$hfind(helpreqs,$nick).data) {
    hadd -ms helpreqs $calc($hget(helpreqs,0).item + 1) $nick
    echo -st $nick added to list
  }
[color:red]}[/color]
Posted By: Remo Re: Why is this not working? - 31/01/05 07:20 AM
okay.... dumb me.... frown
Well on join works now *trumpet sounds and people yelling Hail to the brackets*
Then a voice on the back "Hey the login method still wont work!" and its all sad again"
What I mean was. Thanks! on join works now laugh.
Posted By: Iori Re: Why is this not working? - 31/01/05 07:32 AM
Okay what data is in the %helperpass variable?
Posted By: Remo Re: Why is this not working? - 31/01/05 07:46 AM
the helpers password, wich is hpass
Posted By: Iori Re: Why is this not working? - 31/01/05 08:01 AM
Then it should work fine
Try this, if this worls you probably have another text event which is conflicting.
Code:
on *:text:hlogin &:?:{
  if ($2 == %helperpass) {
    hadd -sm helpers $nick 1
    msg $nick Helper $nick added succesfully
  }
}
Posted By: Remo Re: Why is this not working? - 31/01/05 08:12 AM
Ok now it works. Thanks a lot. Really mean it.
I had one extra command for helpers at the end of that file..... just sent the login to another file and all the commands in another file and works fine.


Thank you all.
© mIRC Discussion Forums