mIRC Home    About    Download    Register    News    Help

Print Thread
#252579 27/04/15 07:22 PM
P
powerade661
powerade661
P
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
}


Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
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".

P
powerade661
powerade661
P
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.

P
powerade661
powerade661
P
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

Last edited by powerade661; 27/04/15 08:51 PM.
S
Sakana
Sakana
S
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

P
powerade661
powerade661
P
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?

P
powerade661
powerade661
P
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.
  }
}

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

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

Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
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?

S
Sakana
Sakana
S
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

P
powerade661
powerade661
P
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.

P
powerade661
powerade661
P
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

Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
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))
  }
}

P
powerade661
powerade661
P
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.

Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
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.

P
powerade661
powerade661
P
For example if the command is potato they have to type !potato instead of just "potato". Is this possible?

Joined: Feb 2003
Posts: 3,412
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,412
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?

P
powerade661
powerade661
P
This did it for me, thank you smile


Link Copied to Clipboard