mIRC Homepage
Posted By: Kurdish_Assass1n Script help - 04/11/06 05:09 PM
ok guys, I have this script which hides all the channels that I'm on, and, if I'm on a specific channel that I can't stay on when I leave, it leaves auto. Here's the code:
Code:
alias f8 scon -a windows
alias windows {
  [color:red]if ($me isop #dynasty_help) { mode #dynasty_help -o $me }
  if ($me isop #helpcom) { mode #helpcom -o $me }
  if ($me isop #dyn_staff) { mode #dyn_staff -o $me }
  if ($me isop #dyn_scripting) { mode #dyn_scripting -o $me }
  if ($me isop #xbc_opers) { mode #xbc_opers -o $me }
  if ($me ison #ascii_art) { part #ascii_art }
  if ($me ison #xbc_help) { part #xbc_help }
  if ($me ison #xbc_game) { part #xbc_game }[/color]
  var %z = 1
  while ($chan(%z)) {
    window $iif($window($v1).state == hidden,-w,-h) [ $v1 ]
    inc %z
  }
  window $iif($window(Status Window).state == hidden,-w,-h) "Status Window"
}

what I'm trying to do is that if I come back within a minute (Pressing F8), then, it won't do any of the red part above, Anyone understand this? Please help if you can, I don't know where to go from here.
Posted By: KingTomato Re: Script help - 04/11/06 05:51 PM
Code:
alias f8 {
  scon -a windows
  if ($timer(deop_and_part)) .timerdeop_and_part off
}
alias windows {
  .timerdeop_and_part 1 60 /deop_and_part
  
  var %z = 1
  while ($chan(%z)) {
    window $iif($window($v1).state == hidden,-w,-h) [ $v1 ]
    inc %z
  }
  window $iif($window(Status Window).state == hidden,-w,-h) "Status Window"
}
alias -l deop_and_part {
  if ($me isop #dynasty_help) { mode #dynasty_help -o $me }
  if ($me isop #helpcom) { mode #helpcom -o $me }
  if ($me isop #dyn_staff) { mode #dyn_staff -o $me }
  if ($me isop #dyn_scripting) { mode #dyn_scripting -o $me }
  if ($me isop #xbc_opers) { mode #xbc_opers -o $me }
  if ($me ison #ascii_art) { part #ascii_art }
  if ($me ison #xbc_help) { part #xbc_help }
  if ($me ison #xbc_game) { part #xbc_game }
}


Untested so let me know if it works, but this should do as prescribed. I added a timer that will go off a minute from pressing the f8 button. If the f8 button is pressed again and the timer is on (i.e. pressed again in the 1 minute window as you mentioned) they will not part/deop.

If you have any questions, please feel free to ask.
Posted By: Kurdish_Assass1n Re: Script help - 04/11/06 06:02 PM
I took out the dot in front of the timer, and, it doesn't leave any channels, this is what I get back:
Quote:

-
* Timer deop_and_part halted
-
* Timer deop_and_part halted
-


it doesn't deop or part anything frown
Posted By: MikeChat Re: Script help - 04/11/06 06:36 PM
try just reversing the order here
alias f8 {

scon -a windows

if ($timer(deop_and_part)) .timerdeop_and_part off

}

to

alias f8 {

if ($timer(deop_and_part)) .timerdeop_and_part off

scon -a windows

}

it looks like it turned on a timer, then checked to see if the timer was on a shut it off
Posted By: KingTomato Re: Script help - 04/11/06 06:40 PM
When you initially press f8 it won't deop or part--it should wait one minute before doing so. If you press f8 within that one minute time, it will "stop" the deop/part progress.

Is this not what happens? I see nothing visible as to why it wouldn't do this.

Edit
MikeChat, I see now. You're absolutely right, it's setting it then removing it. Try this:

Code:
alias f8 {
  if ($timer(deop_and_part)) {
    /set -u0 %f8_do_not_use_timer 1
    .timerdeop_and_part off
  }
  scon -a windows
}

alias windows {
  if (!%f8_do_not_use_timer) .timerdeop_and_part 1 60 /deop_and_part

  var %z = 1
  while ($chan(%z)) {
    window $iif($window($v1).state == hidden,-w,-h) [ $v1 ]
    inc %z
  }
  window $iif($window(Status Window).state == hidden,-w,-h) "Status Window"
}

alias -l deop_and_part {
  if ($me isop #dynasty_help) { mode #dynasty_help -o $me }
  if ($me isop #helpcom) { mode #helpcom -o $me }
  if ($me isop #dyn_staff) { mode #dyn_staff -o $me }
  if ($me isop #dyn_scripting) { mode #dyn_scripting -o $me }
  if ($me isop #xbc_opers) { mode #xbc_opers -o $me }
  if ($me ison #ascii_art) { part #ascii_art }
  if ($me ison #xbc_help) { part #xbc_help }
  if ($me ison #xbc_game) { part #xbc_game }
}
Posted By: Kurdish_Assass1n Re: Script help - 04/11/06 09:43 PM
ok, i'm on about 5 different servers, does that affect the script, because it's still not working frown
Posted By: MikeChat Re: Script help - 04/11/06 11:33 PM
try this
Code:
on *:start:{ start-timer }

alias f8 {
  if ($timer(deop_and_part)) .timerdeop_and_part off
  start-timer
}

alias start-timer {
  .timerdeop_and_part 1 60 scon -at1 deop_and_part
}

alias -l deop_and_part {
  if ($me isop #dynasty_help) { mode #dynasty_help -o $me }
  if ($me isop #helpcom) { mode #helpcom -o $me }
  if ($me isop #dyn_staff) { mode #dyn_staff -o $me }
  if ($me isop #dyn_scripting) { mode #dyn_scripting -o $me }
  if ($me isop #xbc_opers) { mode #xbc_opers -o $me }
  if ($me ison #ascii_art) { part #ascii_art }
  if ($me ison #xbc_help) { part #xbc_help }
  if ($me ison #xbc_game) { part #xbc_game }
}


Tested as written and it closed the same channel name on two networks.

When using multiserver coding it is important that vars or identifiers are not called on the same line as a scid or scon command, this is because of the way mIRC evaluates the line twice, just like you had put $eval(%var,2)
Because you are not evaluating a var or identifier carried in from an on text type event (or other external event) having the alias called on the same line as the scon should be fine.

I will leave it to you to deal with the window status if that matters
Posted By: Kurdish_Assass1n Re: Script help - 06/11/06 02:21 AM
here's what I have MikeChat, I used your code, and, it works, but the problem is that I tested it, and, it always leaves, even if I come back within the amount of time given, i don't know if this is just me, but, if someone can look at why this is doing so, I tried to look at it, but, I hate working with timers.
Code:
on *:start:{ start-timer }

alias f8 {
  scon -a windows
  if ($timer(deop_and_part)) timerdeop_and_part off
  start-timer
}

alias start-timer {
  timerdeop_and_part 1 6 scon -at1 deop_and_part
}

alias -l deop_and_part {
  if ($me isop #dynasty_help) { mode #dynasty_help -o $me }
  if ($me isop #helpcom) { mode #helpcom -o $me }
  if ($me isop #dyn_staff) { mode #dyn_staff -o $me }
  if ($me isop #dyn_scripting) { mode #dyn_scripting -o $me }
  if ($me isop #xbc_opers) { mode #xbc_opers -o $me }
  if ($me ison #testing) { echo -a LEFT TESTING }
  ;if ($me ison #ascii_art) { part #ascii_art }
  if ($me ison #xbc_help) { part #xbc_help }
  if ($me ison #xbc_game) { part #xbc_game }
}
alias windows {
  var %z = 1
  while ($chan(%z)) {
    window $iif($window($v1).state == hidden,-w,-h) [ $v1 ]
    inc %z
  }
  window $iif($window(Status Window).state == hidden,-w,-h) "Status Window"
}

notice: i took out the dots before the timers so I could see if it worked.
Please help if you can.
Posted By: RusselB Re: Script help - 06/11/06 03:21 AM
I don't know if this might be the reason, but you've got the timer set for 6 seconds, rather than 60 seconds as shown in Mike's original code.

Also, I note that the F8 alias turns off the timer (if it's active) and then restarts it (via the start-timer alias).

With these two things, realistically, you've got a deop & part timer running every 6 seconds, even though you have it set for a single run.

I see nothing in the script to "pause" the timer
Posted By: Kurdish_Assass1n Re: Script help - 06/11/06 06:42 PM
I made it 6 seconds so I could test it quickly, but, I guess you're right, nothing is there to pause it, I really don't know how to mess with timers very well.
Posted By: RusselB Re: Script help - 06/11/06 11:21 PM
While the timers technically have a pause/resume option, it does not work the way most people would expect it to work.

Example: A timer running for 60 seconds is paused at 30 seconds.
Then the timer is resumed 45 seconds later.

Most people would expect that the timer would continue for 30 seconds at that point, making it (realistically) a 105 second timer.

However, in practice (and I've seen this mentioned in the bug reports section before) the timer does not do this, and simply executes the command(s) when the timer is resumed. The actual timer keeps counting to the 60 second mark, then stops and holds the command until the timer is resumed.

Realistically you're going to have to have something that will start/stop the timer.
Posted By: Kurdish_Assass1n Re: Script help - 06/11/06 11:49 PM
oh, so is there any possible way to fix this?
Posted By: RusselB Re: Script help - 07/11/06 01:16 AM
Give this a try..it's going at it in a different manner
Code:
 on *:input:*:{
  .timeractive 1 60 scon -at1 deop_and_part
}
alias -l deop_and_part {
  if ($me isop #dynasty_help) { mode #dynasty_help -o $me }
  if ($me isop #helpcom) { mode #helpcom -o $me }
  if ($me isop #dyn_staff) { mode #dyn_staff -o $me }
  if ($me isop #dyn_scripting) { mode #dyn_scripting -o $me }
  if ($me isop #xbc_opers) { mode #xbc_opers -o $me }
  if ($me ison #testing) { echo -a LEFT TESTING }
  ;if ($me ison #ascii_art) { part #ascii_art }
  if ($me ison #xbc_help) { part #xbc_help }
  if ($me ison #xbc_game) { part #xbc_game }
}
on me:*:join:#:{
  .timeractive 1 60 scon -at1 deop_and_part
}
 

When you join the first channel, the timer "active" gets set
Every channel that you join after that, resets the timer "active"
If you don't type anything for a period of 60 seconds, then the deop & part alias kicks in.
If you do type something, doesn't matter if it's in channel or pm, then the timer "active" gets reset.
Posted By: MikeChat Re: Script help - 07/11/06 01:38 AM
i still think this isnt quite right, but closer
Code:
on *:start:{ start-timer }

alias f7 {
  start-timer
}

alias start-timer {
  timerdeop_and_part 0 60 scon -at1 deop_and_part
}

alias -l deop_and_part {
  if ($me isop #dynasty_help) { mode #dynasty_help -o $me }
  if ($me isop #helpcom) { mode #helpcom -o $me }
  if ($me isop #dyn_staff) { mode #dyn_staff -o $me }
  if ($me isop #dyn_scripting) { mode #dyn_scripting -o $me }
  if ($me isop #xbc_opers) { mode #xbc_opers -o $me }
  if ($me ison #testing) { echo -a LEFT TESTING }
  ;if ($me ison #ascii_art) { part #ascii_art }
  if ($me ison #xbc_help) { part #xbc_help }
  if ($me ison #xbc_game) { part #xbc_game }

  scon -at1 windows
}

alias windows {
  var %z = 1
  while ($chan(%z)) {
    echo -s $window($chan(%z)).state
    window $iif($window($chan(%z)).state == normal,-h,-w3) $chan(%z)
    inc %z
  }
  window $iif($window(Status Window).state == hidden,-w,-h) "Status Window"
}


your $v1 wasnt working as you expected I think
your status I may have wrong, but the hidden state from w0 and w1 both returned normal
the -h does hide it
© mIRC Discussion Forums