mIRC Homepage

Please help, I am confused

Posted By: powerade661

Please help, I am confused - 27/04/15 07:22 PM

So I am trying to make a command activate if a specific username types in a command is this possible? Here is what I have so far.

Code:
on *TEXT:hello:#: {
  if ($nick == coolkid661 #) 
  msg $chan Hello how are you
}

Posted By: Majeye

Re: Please help, I am confused - 27/04/15 07:42 PM

Originally Posted By: powerade661
So I am trying to make a command activate if a specific username types in a command is this possible? Here is what I have so far.

Code:
on *TEXT:hello:#: {
  if ($nick == coolkid661 #) 
  msg $chan Hello how are you
}



You have an extraneous # in there that isn't needed.

You also have this set up so that it only responds when 'Coolkid661' says "hello".
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 07:48 PM

Ok so it should work if I take out the #. It's not really working with the # in place. Also another thing, I keep getting this script control error, do I need a faster computer to run the bot? Is this normal or anything to worry about.
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 08:50 PM

It's not working at all, I am not sure if it is having issues identifying the username or what. I took out the # to no avail
Posted By: Sakana

Re: Please help, I am confused - 27/04/15 09:34 PM

You're missing brackets { }

Code:
on *TEXT:hello:#: {
  if ($nick == coolkid661) { 
  msg $chan Hello how are you
 }
}


Though you can also do without them sometimes when your code block is on one line

Code:
on *TEXT:hello:#: if ($nick == coolkid661) msg $chan Hello how are you
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 10:00 PM

It's still not working, I don't understand what is going on... Is it possible that it's not recognizing that the user is coolkid661?
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 10:03 PM

Also another question, why isn't this working? I have been trying for hours, I am not exactly sure as to why it's not.

Code:
on *:text:!editcom & *:#: {
  if ($read(commands.ini, ns, $2)) {
    writeini -l $+ $readini commands.ini $2-
    msg # $nick command has been updated.
  }
}
Posted By: Sakana

Re: Please help, I am confused - 27/04/15 10:03 PM

Also a colon missing, didn't notice it ;(
Code:
on *:text:hello:#:{
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 10:10 PM

That fixed my issue, thank you so much! Any idea what is wrong with my editcom code?
Posted By: Majeye

Re: Please help, I am confused - 27/04/15 10:23 PM

Originally Posted By: powerade661
That fixed my issue, thank you so much! Any idea what is wrong with my editcom code?


where did you grab that code from? do you have the entire thing? or just the edit part?
Posted By: Sakana

Re: Please help, I am confused - 27/04/15 10:25 PM

Seems like there are a number of things wrong with that, but I can't really tell what you're trying to do

Look here for how to use writeini and $readini

http://en.wikichip.org/wiki/mirc/ini_files
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 10:26 PM

I have the entire thing, here it is.

Code:

on $*:text:/^!addcom !?(\S+)/iS:#:{
  if ($nick !isop #) return
  writeini commands.ini commands $regml(1) $$3-
  msg # $nick command has been added. 
}

on $*:text:/^!delcom !?(\S+)/iS:#:{
  if ($nick !isop #) return
  remini commands.ini commands $regml(1)
  msg # $nick command has been removed.
}
on *:text:!editcom & *:#: {
  if ($read(commands.ini, ns, $2)) {
    writeini -l $+ $readini commands.ini $2-
    msg # $nick command has been updated.
  }
}
on $*:text:/^!(\S+)/:#:{
  if ($nick !isop #) return
  if ($readini(commands.ini,n,commands,$regml(1))) msg # $v1
}




Everything works except the editcom.
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 10:34 PM

I am trying to use custom commands. The addcom and delcom work perfectly but the editcom doesn't write the updated command to commands.ini
Posted By: Majeye

Re: Please help, I am confused - 27/04/15 10:44 PM

Try this one instead.

Code:
on *:text:!addcom *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) is already exist into the database! | return }
    write # $+ commands.txt $2-
    msg $chan /me + Command $2 has been added to the database!
  }
}
on *:text:!delcom *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -dl $+ $readn # $+ commands.txt
    msg $chan /me - Command $2- has been deleted from the database!
  }
}
on *:text:!editcom & *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -l $+ $readn # $+ commands.txt $2-
    msg $chan /me -> Command $2 has been updated!
  }
}
ON *:TEXT:*:#: {
  var %owner $right(#,-1)
  tokenize 32 $strip($1-,burci)
  if ($read(# $+ commands.txt, nts, $1)) {
    var %com = $v1
    var %com = $replace(%com,@user@,$iif($2,$2,?),@nick@,$nick,@target@,$target)
    if (-ul=mod == $gettok(%com,1,32)) && (!$mod($nick)) { msg $chan Sorry $nick $+ , you cannot use this command. | return }
    if (-ul=reg == $gettok(%com,1,32)) && (!$mod($nick)) && (!$regular($nick)) { msg $chan Sorry $nick $+ , you cannot use this command. | return }
    if (-ul=own == $gettok(%com,1,32)) && ($nick != %owner) { msg $chan Sorry $nick $+ , you cannot use this command. | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32) || -ul=reg == $gettok(%com,1,32) || -ul=own == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}
Posted By: powerade661

Re: Please help, I am confused - 27/04/15 10:57 PM

Is it possible to make it to where they have to type something before the command for example !command rather than just typing the specific text? This works great! If not, that is fine.
Posted By: Majeye

Re: Please help, I am confused - 28/04/15 12:36 AM

Originally Posted By: powerade661
Is it possible to make it to where they have to type something before the command for example !command rather than just typing the specific text? This works great! If not, that is fine.


I'm not sure I fully understand this question.
Posted By: powerade661

Re: Please help, I am confused - 28/04/15 04:23 AM

For example if the command is potato they have to type !potato instead of just "potato". Is this possible?
Posted By: sparta

Re: Please help, I am confused - 29/04/15 09:43 AM

on *:text:!addcom *:#: <- this part telling mirc what to look for, remove the ! sign will make mirc look for addcom, and that without the ! sign, i dont know if that is what you looking for?
Posted By: powerade661

Re: Please help, I am confused - 30/04/15 06:01 AM

This did it for me, thank you smile
© 2019 mIRC Discussion Forums