mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings,

Does someone have some ideas on how I can implement a userlevel or Op/Owner only ability to this example of a whispered command to our Script?

on ^*:TEXT:test2*:?:{ /msg $active (*) Topic of the moment suggestion Is test 2 }


Thanks for your time and consideration,
MDA



Joined: Dec 2002
Posts: 208
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 208
although i personaly recomend codeig a custom user level system. mIRC does have a built in user level system

users can be added with the /auser or /guser commands,

on LEVEL:EVENT:ARGS: { code }

or

on *:EVENT:ARGS: { if ($level($fulladdress) == LEVEL) { code } }

the first example shows you the LEVEL can be placed as a prefix to the event, usualyusers use a '1' or a '*' here, which would alow you to have the same event work for multipal levels useing the 2nd example which alows you to define condiitonals for each one to do what u want.

for example:
Code:
on 20:TEXT:*:#: {
  if ($me isop $chan) {
    if ($1 == !op) { mode $chan +o $nick }
    if ($1 == !kick) { kick $chan $$2 $3- }
  }
  if ($1 == !part) { part $chan $2- }
}


obviously there are hundereds of different ways this could be coded .. but htis is a very simplistic example of how you might do somethign along these lines, the above example will alow a nick of level 20 or higher to issue the !commands contained inside the conditionals.

hope this helped, if it just confused ya more ask and ill try beter to explain hehe.

Cobra^

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings Cobra,

The example and need we have is mostly specific, a response to a whispered command only to a specified userlevel or higher. I think if I use your example of the if ($1 == !op) that might work. Although I'm not sure if that will still trigger for a channel Owner thou, but I'll test that in test2.

on ^*:TEXT:test1*:?:{ if ($1 ==op) /msg $active (*) Topic of the moment suggestion Is test 1 }

or perhaps

on ^*:TEXT:test2*:?:{ if ($1 >=op) /msg $active (*) Topic of the moment suggestion Is test 2 }


Thanks for your suggestions,
MDA

Last edited by MDA; 21/12/02 11:04 PM.
Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Ok,

We tried the following tests, all failed to screen only for Op/Owner.

on ^*:TEXT:test7*:?:{ if ($1 >=!op) /msg $active (*) Topic of the moment suggestion Is test 7 }
on ^*:TEXT:test8*:?:{ if ($1 >=op) /msg $active (*) Topic of the moment suggestion Is test 8 }
on ^*:TEXT:test9*:?:{ if ($1 >= op) /msg $active (*) Topic of the moment suggestion Is test 9 }
on ^*:TEXT:test10*:?:{ if ($1 isowner) /msg $active (*) Topic of the moment suggestion Is test 10 }

Any further suggestions?

Regards,
MDA

Joined: Dec 2002
Posts: 208
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 208
hi, clearly there is a misscomunication, sorry

i'm not able to understand exactly what your trying to do .. your useing a >= comparison operator in regards to a string !op ...

please try to be very specific with words exactly what u want to happen and when u want it to happen and ill respond with the solution. ty

Cobra^

Joined: Dec 2002
Posts: 208
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 208
it occured to me that you may be useing the term 'wisper' in place of what mIRC would call a query or privit msg, and by userlevel u actualy mean rank in a channel, op, voice etc

if this is the case, there is one issue, in that in a privit msg event with a specific person, mIRC will not know which channel your refering to in regards to access, u could either define the channel name yourself and check it, or you could loop though all the common channels between you and $nick.. the following example is if u wish to define a channel specific privit msg event:

Code:
on *:TEXT:*:?: {
  if ($nick isop #channel) {
    if ($1 == !trigger) { msg $nick * info }
  }
}


in this case, mIRC will check to see if $nick is op in '#channel' (u will need to change #channel to the name of the channel uw ish to check) and if they typed '!trigger' (u will need to replace this with whatever u wish the triger to be) it will msg $nick with info (replace info with the test u wish mirc to send to them)

hope this is what u were looking for, if not refer to my previous post

Cobra^

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings Cobra,

Thanks again for your suggestions, we finally were able to find the commands which permited this to function properly for us.

on ^*:text:test1*:?:{ if ($nick isop $active) /privmsg $active the following..Host test 1 is successful... }

This is a text whisper to a script of in this example test1*, and only a host (op) or owner is able to trigger the reply which is posted by the scripts reply into the main active channel and not back to them as a whisper.


Regards,
MDA

Joined: Dec 2002
Posts: 208
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 208
sure.. asuming that $active is the chan u want.. what if your looking at anouther window?

if you rhappy with that great.. but its slopy codeing .. $active could be the status window...

look into $comchan()

Cobra^

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Cobra,

I'm using this command string to post a message into the main chatroom /privmsg $active because it works. If there's a working example of the $comchan() that you have then I'll try that. I'm assuming its a force to a specific channel, what's the syntax for the material or variable in the brackets?

I'll check some of the scripts we have on the msn chat servers, I have not seen the $comchan() variable used before on them, if it works there and I can 'verify' its function then Yes I would be pleased and happy to recode and include that. I'll also search and look into some tutorial examples on the $comchan() for further ideas.


Thanks for your time and consideration,
MDA

Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
$comchan(nick,N)
Returns the names of channels which both you and nick are on.

Properties: op, help, voice,

$comchan(nick,0) returns the total number of common channels
$comchan(nick,1) returns the first common channel name
$comchan(nick,1).op returns $true if you're an op on the channel


^From the help file.

Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Your code works because you apparently never leave that channel window. $active literally means "whichever window I currently have as the active window, whatever it happens to be." $comchan($nick,1) means "the first common channel I share with $nick"; however, there might be more than one common channel between you and $nick. That would require that you set up a loop index variable and loop through $comchan($nick,%i) until it becomes undefined.

The reason you need this is that you are looking to catch private messages directly to you (or your script) which is what the :?: part means. This also means that there will be no #channel associated with that event, so you cannot use $chan. In order to find the channels they share with you, you must use $comchan($nick,%i) as described below. This is a very simple task, one that you will use repeatedly throughout your scripting career.

Below you will find just the snippet of code, completely commented, that you will use (usually without such comments) to perform $comchan() type tasks, such as in on QUIT or on NICK or on *:TEXT/ACTION/NOTICE:*:?: events. It, or at least its idea, may be inserted anywhere that you need this kind of code.
Code:

  ;
  ;  Set up the loop index to start with the first common channel (if any).
  ;
  var %i = 1
  ;
  ;  Assume we have 3 common channels with this nick. Once %i is incremented to 4, then $comchan($nick,4) will 
  ;  fail the conditional test and we will drop out of the loop. If someone who is not on any channels with us 
  ;  triggers this remote, then $comchan($nick,1) will fail and we won't even process the loop at all.
  ;
  ;  $comchan($nick,1000) would return $null since we cannot possibly be on that many channels with them; by the
  ;  same token, if we share only 3 channels with them, then $comchan($nick,4) will also return $null and drop us
  ;  out of the loop.
  ;
  ;  $null == 0 == $false ... all three of those values will fail a conditional test. We'll look for $null in this 
  ;  instance.
  ;
  while ($comchan($nick,%i)) {
    ;
    ;  Here is where you will put the commands now that you have a channel to work with. If you have no further 
    ;  IF conditions inside this portion of the code, you can use $ifmatch throughout as the equivalent of $chan.
    ;  $ifmatch holds whatever the matching last condition was; in this case, it holds what is in the while condition
    ;  that matched - $comchan($nick,%i) - without having to resolve it again. If you have further IF-ELSEIF-ELSE 
    ;  tests to run, then you can set up a temporary local variable (such as %chan) to hold the name of the current
    ;  channel.
    ;
    ;  var %chan = $ifmatch
    ;
    ;  Do any commands you wish here.
    ;
    msg $ifmatch Host test 1 is successful.
    ;
    ;  Once you are finished with this common channel for $nick, increment %i to move to the next common channel
    ;  next time through the looping while condition.
    ;
    inc %i
  }

Your code uses the prefix ^ which is used in conjunction with the haltdef command to halt the default text. By itself, it does nothing (except in certain specific cases which do not currently apply to you); you can leave that part off. So, for a more complete example, using yours as the guide and omitting the comments, here is what your code should look like to respond to a /msg MDA test1 and posting the resulting msg in each common channel you share with $nick.
Code:

on *:TEXT:test1:?:{
  var % i = 1
  while ($comchan($nick,%i)) {
    msg $ifmatch Host test 1 is successful.
    inc %i
  }
}

If you only wanted this remote to react for a single, specific channel and only if you both are on that channel as well, then you can hard-code in the channel name, like this:
Code:

on *:TEXT:test1:?:{
  if (($me ison #MDAsChannel) && ($nick ison #MDAsChannel)) {
    msg #MDAsChannel Host test 1 is successful.
  }
}

If you wish to omit the check to see if they are on the channel, use this:
Code:

on *:TEXT:test1:?:{
  if ($me ison #MDAsChannel) {
    msg #MDAsChannel Host test 1 is successful.
  }
}

If you wish to omit the check to see if you are both on the channel because, perhaps because the channel accepts messages from nicks that are not on the channel (-n channel mode on most IRCds), just use the msg #MDAsChannel command without the IF and its conditions.
Code:

on *:TEXT:test1:?:{
  msg #MDAsChannel Host test 1 is successful.
}

I hope that this has explained how to use $comchan() to your satisfaction. By reading /help $comchan while keeping this in front of you, you should be able to grasp exactly how it works now.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings Collective, Cobra

I've tried multiple adjustments with the ($comchan(nick,1).op) command in that statement and none this far have output any message into the channel at all. The impasse that I have run into is that although the following script command line functions for us via a remote whisper and a main chat channel reply its not giving us the $2 variable.

Again we are specifically needing a remote whisper to the script and a main chat channel reply from the script which anyone in that chat channel is able to see.

on ^*:text:@test*:?:{ if ($nick isop $active) /privmsg $active Host test 1 is successful for $2 ... }

for example @test beta
It fails to pickup on the $2 variable and just posts

Host test 1 is successful for $2 ... }

instead of what we need

Host test 1 is successful for beta ... }

Anyone have any thoughts on how we can get that $2 variable to function in that command for us?

Some of the ($comchan(nick,1).op) we tried and which all failed to post anything are the following.

on ^*:text:test2*:?:{ if ($comchan(nick,1).op) /privmsg $active the following..Host test 2 is successful... }
on ^*:text:test3*:?:{ if ($comchan(nick,1).op) /msg $comchan(nick,1) the following..Host test 3 is successful... }
on ^*:text:test4*:?:{ if ($comchan(nick,1).op) /privmsg $comchan(nick,1) the following..Host test 4 is successful... }

Thanks for your time and consideration,
Regards,
MDA

Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Replace the "$comchan(nick,1)" with "$comchan($nick,1)".

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Thanks Hammer and Collective

I'm very appreciative of your explainations and your examples. You outlined quite afew examples of that function and I'll work with them to see which ones we can get to function for us.

Collective I believe we first tried the following these tests which failed to output any messages, I'll run them again to see, thank you.

on ^*:text:test1*:?:{ if ($comchan($nick,1).op) /privmsg ($comchan($nick,1) the following..Host test 2 is successful $2 ... }

on ^*:text:test2*:?:{ if ($comchan($nick,1).op) /msg ($comchan($nick,1) the following..Host test 2 is successful $2 ... }


Thank you for your time and consideration,
MDA

Last edited by MDA; 22/12/02 05:58 AM.
Joined: Dec 2002
Posts: 9
D
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
D
Joined: Dec 2002
Posts: 9
Try breaking the pieces down into smaller chunks just for testing.

on *:TEXT:test1*:?: { /privmsg $comchan($nick,1) Test1 $2- }

It also sometimes helps to add local echos for variables so YOU know what mIRC is actually seeing (I do this a lot while building new code). Also, at least while building the command you might want to put everything on it's own line in case you get an error message back.

on *:TEXT:test1*:?: {
echo -s comchan is $comchan($nick,1) nick is $nick 2- is $2-
privmsg $comchan($nick,1) Test1 $2-
}

Once you get that command working, then try adding in the op check.

On whisper response remote access commands, I always just fill another variable rather than use a direct comchan. This is so I can use whisper & main room response commands in the same command.

on *:TEXT:!kick*:*: { set %chan $comchan($nick,1) | kick %chan $2 $3- }

This command, for example, allows someone to type in the main room OR via whisper !kick user reason.

Of course, I wouldn't recommend that because that command has no access limitations. smile


Link Copied to Clipboard