mIRC Homepage

Need help with "channel owner" only script

Posted By: Majeye

Need help with "channel owner" only script - 13/10/14 09:47 PM

Greetings, everyone.

I really dislike making new threads when I know this exists already, just having a difficult time finding the thread(s) with this scripting already in them.

I am having a hard time trying to find the script that only allows channel-owners only to make use of commands.

Any help appreciated.
Posted By: westor

Re: Need help with "channel owner" only script - 13/10/14 09:55 PM

You must use 'ISOP' if statement on your event.

Help details: /help isop

i will give you some examples:

e.g:

Code:
ON !*:TEXT:!COMMAND:#MY_CHANNEL: {
  if ($nick isop $chan) { echo -a OK $nick is an channel operator }
  elseif ($nick !isop $chan) { echo -a ERROR $nick is NOT an channel operator }
}

Posted By: Majeye

Re: Need help with "channel owner" only script - 13/10/14 11:07 PM

I thought there was a way to make it so that only the channel owner could do it...

I don't remember the actual scripting off hand (which is the purpose of this thread), but isop makes it so all channel operators (moderators) can use the specified command, instead of just the channel owner (or just 1 specified person)

I do remember you had to put the actual persons username in the script somewhere, just don't remember what the script looked like.

all I remember was something like ( username | anotherusername) or something to that effect.
Posted By: westor

Re: Need help with "channel owner" only script - 13/10/14 11:14 PM

Ah ok if you want this there is an other way, you can create a file on your system e.g: owners.txt and add there the nicks that you want and use this code:

This code stop from any command if the user is NOT on the 'owners.txt' file.

Code:
ON *!:TEXT:!*:#: {
  var %rn = $read(owners.txt,ntw,$nick)
  if (%rn) && (%rn !== $nick) { halt }
}


Example of the 'owners.txt'

nick1
nick2
nick3
...
Posted By: Nillen

Re: Need help with "channel owner" only script - 14/10/14 07:24 AM

An extension to this, owners are always the same $nick as the #channel name on twitch. Example (nillens and #nillens) So for my own script where I use userlevels I have a check for
Code:
$nick == $mid(#,2)
and from an ini file.

But what I believe Majeye was looking for was a simple if statement like:
Code:
if ($nick != username) return
and I suggest you read the help files regarding these matters.
/help if then else
/help $nick
etc
Posted By: hixxy

Re: Need help with "channel owner" only script - 14/10/14 07:16 PM

Do owners have a different mode prefix?

E.g. some networks use either a '.' or a '~' to signify owners.
Posted By: Nillen

Re: Need help with "channel owner" only script - 14/10/14 07:32 PM

Nope, they do not. They're simply labeled and treated as ops as well from the server.
Posted By: Majeye

Re: Need help with "channel owner" only script - 14/10/14 10:01 PM

Originally Posted By: Nillen
An extension to this, owners are always the same $nick as the #channel name on twitch. Example (nillens and #nillens) So for my own script where I use userlevels I have a check for
Code:
$nick == $mid(#,2)
and from an ini file.

But what I believe Majeye was looking for was a simple if statement like:
Code:
if ($nick != username) return
and I suggest you read the help files regarding these matters.
/help if then else
/help $nick
etc


That is exactly what I was seeking.

Unfortunately i'm still having difficulty getting it to work properly.. mind looking over the following code and pointing out where I went wrong?

Code:
on $*:text:/!karma (add|remove)/Si:#thebluemuzzy:{
  if ( $nick == thebluemuzzy ) { return } {
    if ($0 < 3) { msg # Insufficient parameters: Use !karma <add|remove> <user> [number] | return }
    writeini -n Karma.ini $+(#,.,$3) Points $calc($readini(Karma.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Karma.ini,$+(#,.,$3),Points) total karma. }
  }
  else { msg $chan This command is only available to TheBlueMuzzy. }
}


Nevermind.. fixed it myself with:

Code:
on $*:text:/!karma (add|remove)/Si:#thebluemuzzy:{
  if ( $nick == thebluemuzzy ) { 
    if ($0 < 3) { msg # Insufficient parameters: Use !karma <add|remove> <user> [number] | return }
    writeini -n Karma.ini $+(#,.,$3) Points $calc($readini(Karma.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Karma.ini,$+(#,.,$3),Points) total karma. }
  }
  else { msg $chan This command is only available to TheBlueMuzzy. }
}
Posted By: Majeye

Re: Need help with "channel owner" only script - 14/10/14 10:33 PM

Now that I have that fixed.. I'm curious as to how a 2nd name can be added to the command?

I thought it was something like this (but doesn't seem to work):

Code:
on $*:text:/!karma (add|remove)/Si:#thebluemuzzy:{
  if ( $nick == thebluemuzzy | $nick == majeye ) { 
    if ($0 < 3) { msg # Insufficient parameters: Use !karma <add|remove> <user> [number] | return }
    writeini -n Karma.ini $+(#,.,$3) Points $calc($readini(Karma.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Karma.ini,$+(#,.,$3),Points) total karma. }
  }
  else { msg $chan This command is only available to TheBlueMuzzy & Majeye. }
}
Posted By: westor

Re: Need help with "channel owner" only script - 14/10/14 11:00 PM

Originally Posted By: Majeye
Now that I have that fixed.. I'm curious as to how a 2nd name can be added to the command?

I thought it was something like this (but doesn't seem to work):

Code:
on $*:text:/!karma (add|remove)/Si:#thebluemuzzy:{
  if ( $nick == thebluemuzzy | $nick == majeye ) { 
    if ($0 < 3) { msg # Insufficient parameters: Use !karma <add|remove> <user> [number] | return }
    writeini -n Karma.ini $+(#,.,$3) Points $calc($readini(Karma.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Karma.ini,$+(#,.,$3),Points) total karma. }
  }
  else { msg $chan This command is only available to TheBlueMuzzy & Majeye. }
}


Try use this code:

Code:
on $*:text:/!karma (add|remove)/Si:#thebluemuzzy: {
  var %nicks = thebluemuzzy majeye
  if ($istok(%nicks,$nick,32)) { 
    if ($0 < 3) { msg # Insufficient parameters: Use !karma <add|remove> <user> [number] | return }
    writeini -n Karma.ini $+(#,.,$3) Points $calc($readini(Karma.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Karma.ini,$+(#,.,$3),Points) total karma. }
  }
  else { msg $chan This command is only available to %nicks nickname(s). }
}
© 2020 mIRC Discussion Forums