mIRC Homepage
Posted By: PhyxiuS Need help with "!avail" thing... - 07/10/05 10:49 AM
Hi, i already created a couple of scripts by myself, but none of them worked... Maybe there is someone who can help me with this stuff ! blush

What i need:

When i say: !avail or !addme , the script add's me to the topic... but then, when another member says: !avail or !addme, the script add his nick, but mine is gone... So, when members say !avail ... the nicknames have to stay in the topic.

Like:
<Bla> !avail
Topic: Avaible: [Bla,,,,]
<BooM> !avail
Topic: Avaible: [Bla,BooM,,,]
<ZieZ> !avail
Topic: Avaible: [Bla,BooM,ZieZ,,]

This is what i need ...

Thankx anyway... wink
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 01:56 PM
Code:
on *:text:!avail:#yourchan: {
  if ($istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You are already available. | return }
  if ($gettok($chan($chan).topic,2,58) == $null) { topic $chan Available: $nick }
  else topic $chan $chan($chan).topic $+ , $nick
}

* Change #yourchannel to whatever channel you want this for.

Note that you probably want to set a user level to this...

example:
on 100:text:!avail:#youchannel: {

Then, you set your ops (or whoever) to that level and only they could use the command.

Also, here's a unavailable script for you:

Code:
on *:text:!unavail:#yourchan: {
  if (!$istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You are already unavailable. | return }
  topic $chan $remove($chan($chan).topic,$nick $+ $chr(44),$nick)
}


Again, you may want to use a user level for this, and change #yourchannel to whatever channel you want this for.

**EDIT** Thanks to Kelder's script below, I realized you could use $chan($chan).topic to get the topic... I had forgotten about that. So, I've edited this to use that. No need for variables now. laugh
Posted By: Kelder Re: Need help with "!avail" thing... - 07/10/05 02:06 PM
Code:
on *:TEXT:!avail*:#yourchannel:avail_topic $2 $nick
on *:INPUT:#yourchannel:if ($1 == !avail) avail_topic $2 $me
alias avail_topic {
  if ($regex($chan($chan).topic,Available: \[.*\])) {
    if ($regex($chan($chan).topic,Available: \[.*\Q $+ $1 $+ \E.*\])) {
      $iif($1 == $me,echo,msg) $chan you're already in!
      halt
    }
    else var %t, %r = $+($chr(44),$1,]), %q = $regsub($chan($chan).topic,(Available: ?\[.*)\],\1 $+ %r,%t)
  }
  else var %t = $iif($chan($chan).topic,$v1 &lt;&gt;) Available: $+([,$1,])
  topic $chan %t
}
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 02:11 PM
Ok, i tested that, but there are some problems init.

When i say: !avail - i'm added to the topic... & when another one says: !avail... his added to the topic, but then when the the second one who said !unavail his removed, & then i'm the only one on Avaible list, & then when i say: !unavail, i'm not getting removed from topic... so the last one on the avaible list can't be removed, can u fix that problem? confused

[16:13:33] <hYp`PhyX-> !avail
[16:13:34] * UP changes topic to 'Available: hYp`PhyX-,,, hYp`PhyX-, Dj`SlyteX^, hYp`PhyX-'
[16:13:40] <hYp`PhyX-> !unavail
[16:13:40] * UP changes topic to 'Available: hYp`PhyX-,,, Dj`SlyteX^,'
[16:13:49] <hYp`PhyX-> !unavail
[16:13:50] -UP- You are already unavailable.

-

So, plz can someone past me the "correct" code? !avail & !unavail ... i'm not expirienced to this sort of coding frown
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 02:15 PM
That should be fixed in the change I made above. laugh

The problem was all those commas in your topic. I'm not sure why you had all those. Anyhow, the update I made above should work for you.


*** I suggest erasing the topic completely and then using this script so that you're not getting conflicts caused by a topic formatted differently than the script expects.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 02:19 PM
Riamus, can u past me the correct code again? !avail & !unavail ? i'm not expirienced with this sort of coding & i even will do some things wrong by changing the code u gaved me...
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 02:20 PM
Just erase what you put in before and then paste in what is above. The code is correct with the changes already in there.

EDIT:
Well, here it is all put together for you...

Code:
on *:text:!avail:#yourchan: {
  if ($istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You are already available. | return }
  if ($gettok($chan($chan).topic,2,58) == $null) { topic $chan Available: $nick }
  else topic $chan $chan($chan).topic $+ , $nick
}

on *:text:!unavail:#yourchan: {
  if (!$istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You are already unavailable. | return }
  topic $chan $remove($chan($chan).topic,$nick $+ $chr(44),$nick)
}


And, remember what I mentioned about user levels, changing #yourchan to your channel's name (in both spots), and completely erasing your topic before using this script.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 02:33 PM
Ok, thankx! I think it's working now, but look, 1 more problem, if there is someone leaving the channel, without saying !unavail, is it possible to auto remove him? ...

& when someone is using BNC, & his off... without saying !unavail ... is there a command where i can remove him with? like !remove hYp`SlyteX^ .... Cuz this is my problem:


[16:29:59] <hYp`PhyX-> !unavail
[16:29:59] * UP changes topic to 'Available: ,, Dj`SlyteX^,,,'
[16:30:01] <hYp`PhyX-> !avail
[16:30:01] * UP changes topic to 'Available: ,, Dj`SlyteX^,,,, hYp`PhyX-'

- oh... & it would be cool if u could past me a !totally reset command too ... Thankx m8... really wink
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 02:56 PM
Ah, found the issue with the commas, so that's fixed. I also made it so you can do !unavail nick if you want to remove a specific nick yourself, and made it to remove them on quit/part.

And, I added the "!totally reset" command. You may want to change the wording of that to something easier to type (like !reset).

Finally, please don't forget to remove the topic before using this, changing all the #yourchans, and to consider using user levels.

Code:
on *:text:!avail:#yourchan: {
  if ($istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You are already available. | return }
  if ($gettok($chan($chan).topic,2,58) == $null) { topic $chan Available: $nick }
  else topic $chan $chan($chan).topic $+ , $nick
}

on *:text:!unavail*:#yourchan: {
  if ($2 == $null) {
    if (!$istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You already aren't available. | return }
    unavailablenick $nick $chan
  }
  else {
    if (!$istok($remove($chan($chan).topic,44),$2,32)) { .notice $nick $2 isn't marked as available. | return }
    unavailablenick $2 $chan
  }
}

on *:text:!totally reset:#yourchan: {
  topic $chan Available:
}

on *:quit:#yourchan: {
  unavailablenick $nick $chan
}

on *:part:#yourchan: {
  unavailablenick $nick $chan
}

on *:nick: {
  if (!$istok($remove($chan([color:red]#yourchan[/color]).topic,44),$nick,32)) { return }
  var %topic = $remove($chan([color:red]#yourchan[/color]).topic,$nick $+ $chr(44),$nick)
  var %topic = $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
  if ($gettok(%topic,2,58) == $null) { var %topic = Available: $newnick }
  else var %topic = %topic $+ , $newnick
  topic $chan %topic
}

alias unavailablenick {
  if (!$istok($remove($chan($2).topic,44),$1,32)) { return }
  var %topic = $remove($chan($2).topic,$1 $+ $chr(44),$1)
  topic $chan $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
}



***EDIT*** I added a part to change the topic if someone changes their nick. If someone is in the topic as available and they change their nick, the topic will change to show their new nick.

**EDIT AGAIN** Fixed the alias and fixed the /nick event (change the red text in the /nick event)
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 03:21 PM
Ok, the !avail thingy is working nice... & the !reset thing too(not hard) ... but, the quit/part script & the (alias unavailablenick) script is wrong...+ ppl can't !unavail by themselves, is it the "alias unavailablenick" script that's wrong? or...

-------

<hYp`PhyX-> !avail
* UP changes topic to 'Available: hYp`PhyX-'
* hYp`PhyX- has left #hyp.zp
* hYp`PhyX- has joined #hyp.zp
* L sets mode: +o hYp`PhyX-
* fenriz` sets mode: +v hYp`PhyX-
<hYp`PhyX-> !unavail
<hYp`PhyX-> !unavail hYp`PhyX-
<hYp`PhyX-> !totally reset
* UP changes topic to 'Available:'
<hYp`PhyX-> !avail
* UP changes topic to 'Available: hYp`PhyX-'
<hYp`PhyX-> !unavail
<UP> !unavail hYp`PhyX-
<hYp`PhyX-> !unavail
<hYp`PhyX-> !unavail hYp`PhyX-
<hYp`PhyX-> !unavail $me
<hYp`PhyX-> !unavail hYp`PhyX-

--------------

see? frown
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 03:24 PM
My fault. When I switched it to an alias, I forgot to replace $chan... one second.

Ok, the script above is edited. Copy/Paste that over your current copy and it should work fine. Sorry for the confusion.

Ok, one last edit... I changed the /nick event as well since that would also not work with $chan. Just change the red text in it to your channel name. Make sure you copied it after I changed it (after there is red text visible in the script).
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 03:38 PM
Hmm, it looks ok... but it don't changes topic when !unavail ... & it don't change topic when i change nick...

-----

[17:36:16] <hYp`PhyX-> !reset
[17:36:17] * UP changes topic to 'Available:'
[17:36:19] <hYp`PhyX-> !avail
[17:36:19] * UP changes topic to 'Available: hYp`PhyX-'
[17:36:22] <hYp`PhyX-> !unavail
[17:36:29] <hYp`PhyX-> !unavail hYp`PhyX-
[17:36:53] * hYp`PhyX- is now known as hYp`PhyXi-
[17:37:07] <hYp`PhyXi-> !unavail
[17:37:08] -UP- You already aren't available.

-------

[17:39:40] <hYp`PhyXi-> !reset
[17:39:41] * UP changes topic to 'Available:'
[17:39:44] <hYp`PhyXi-> !unavail
[17:39:44] -UP- You already aren't available.
[17:39:52] <hYp`PhyXi-> !avail
[17:39:52] * UP changes topic to 'Available: hYp`PhyXi-'
[17:39:54] <hYp`PhyXi-> !unavail
[17:40:03] <hYp`PhyXi-> !unavail
[17:40:05] <hYp`PhyXi-> !unavail

--------

... u know the problem? :s
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 03:46 PM
Ok, that is fixed. I hope. Copy/Paste the entire code above and try it. laugh

Sorry for the problems. I can't connect from here, so I can't test the script out myself.

Still looking at the /nick part....

To test the /nick part...

Change the nick section to this:
Code:
on *:nick: {
  echo -a $chan(#yourchan).topic ~ $nick
  if (!$istok($remove($chan(#yourchan).topic,44),$nick,32)) { return }
  var %topic = $remove($chan(#yourchan).topic,$nick $+ $chr(44),$nick)
  var %topic = $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
  if ($gettok(%topic,2,58) == $null) { var %topic = Available: $newnick }
  else var %topic = %topic $+ , $newnick
  topic $chan %topic
}

I just added the echo line if you don't want to paste the entire thing.
(Replace the #yourchans)

Then, try changing nicks and tell me what it echos.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 03:53 PM
Ok, sorry for wasting your time m8, but... :

[17:48:48] <hYp`PhyXi-> !reset
[17:48:49] * UP changes topic to 'Available:'
[17:48:57] <hYp`PhyXi-> !avail
[17:48:58] * UP changes topic to 'Available: hYp`PhyXi-'
[17:49:00] <hYp`PhyXi-> !unavail
[17:49:13] * hYp`PhyXi- is now known as hYp`PhyxX
[17:49:44] <hYp`PhyxX> !unavail
[17:49:45] -UP- You already aren't available.
[17:50:19] <hYp`PhyxX> !unavail hYp`PhyXi-
[17:50:46] <hYp`PhyxX> !unavail hYp`PhyXX
[17:50:46] -UP- hYp`PhyXX isn't marked as available.
[17:50:59] <hYp`PhyxX> !unavail
[17:50:59] -UP- You already aren't available.

--- i would check the !unavail thingy... & nick isn't changing in topic either ;\ ... If u think u writed wrong code down... This is what i got:


on *:text:!avail:#hYp.zp: {
if ($istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You are already available. | return }
if ($gettok($chan($chan).topic,2,58) == $null) { topic $chan Available: $nick }
else topic $chan $chan($chan).topic $+ , $nick
}

on *:text:!unavail*:#hYp.zp: {
if ($2 == $null) {
if (!$istok($remove($chan($chan).topic,44),$nick,32)) { .notice $nick You already aren't available. | return }
unavailablenick $nick $chan
}
else {
if (!$istok($remove($chan($chan).topic,44),$2,32)) { .notice $nick $2 isn't marked as available. | return }
unavailablenick $2 $chan
}
}

on *:text:!reset:#hYp.zp: {
topic $chan Available:
}

on *:quit:#hYp.zp: {
unavailablenick $nick $chan
}

on *:part:#hYp.zp: {
unavailablenick $nick $chan
}

on *:nick: {
if (!$istok($remove($chan(#hYp.zp).topic,44),$nick,32)) { return }
var %topic = $remove($chan(#hYp.zp).topic,$nick $+ $chr(44),$nick)
var %topic = $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
if ($gettok(%topic,2,58) == $null) { var %topic = Available: $newnick }
else var %topic = %topic $+ , $newnick
topic $chan %topic
}

alias unavailablenick {
if (!$istok($remove($chan($3).topic,44),$2,32)) { return }
var %topic = $remove($chan($3).topic,$2 $+ $chr(44),$2)
topic $chan $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
}

Oh, wait sec... i'm changing Nick part, one sec.
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 03:56 PM
Your alias isn't changed to match what is above. Change that and the !unavail should work. And, try the echo thing I mentioned to see if we can get the /nick part to work properly.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 04:06 PM
Ok, dude... the !unavail thingy is working great ! & when i'm leaving channel the topic is doing great ! smile Thankx for that

---

But 1 thing is not working... when ppl are avail in topic & change their nicks... Their nick wont change in topic...

Check:

on *:nick: {
echo -a $chan(#yourchan).topic ~ $nick
if (!$istok($remove($chan(#hYp.zp).topic,44),$nick,32)) { return }
var %topic = $remove($chan(#hYp.zp).topic,$nick $+ $chr(44),$nick)
var %topic = $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
if ($gettok(%topic,2,58) == $null) { var %topic = Available: $newnick }
else var %topic = %topic $+ , $newnick
topic $chan %topic
}
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 04:08 PM
Yes... I need to know the output of the echo when you change your nick while being marked as available.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 04:11 PM
on *:nick: {
echo -a $chan(#yourchan).topic ~ $nick
if (!$istok($remove($chan(#hYp.zp).topic,44),$nick,32)) { return }
var %topic = $remove($chan(#hYp.zp).topic,$nick $+ $chr(44),$nick)
var %topic = $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
if ($gettok(%topic,2,58) == $null) { var %topic = Available: $newnick }
else var %topic = %topic $+ , $newnick
topic $chan %topic
}

-

I see what i did wrong
"echo -a $chan(#yourchan).topic ~ $nick"

forgot to change "$chan(#yourchan)"

"(#yourchan)" ... on that line, sorry wink Thankx for all !
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 04:13 PM
It works now when you change your nick?
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 04:20 PM
No :| ... there still something wrong... This is what i've got now:

on *:nick: {
echo -a $chan(#hYp.zp).topic ~ $nick
if (!$istok($remove($chan(#hYp.zp).topic,44),$nick,32)) { return }
var %topic = $remove($chan(#hYp.zp).topic,$nick $+ $chr(44),$nick)
var %topic = $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
if ($gettok(%topic,2,58) == $null) { var %topic = Available: $newnick }
else var %topic = %topic $+ , $newnick
topic $chan %topic
}

--
Still don't changes nick, u know the problem?
--
This is what shows up:

<hYp`PhyX-> !avail
* UP changes topic to 'Available: hYp`PhyX-'
°†° hYp`PhyX- is now known as testinggg
Available: hYp`PhyX- ~ hYp`PhyX- (this is echo line)

...
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 04:48 PM
Sorry, was away. When you change your nick, it should echo something. What does it echo? That's why I added that, so we could see what was echoed.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 04:58 PM
This:

<hYp`PhyX-> !avail
* UP changes topic to 'Available: hYp`PhyX-'
°†° hYp`PhyX- is now known as testinggg
Available: hYp`PhyX- ~ hYp`PhyX- (echo line)
°†° testinggg is now known as hYp`PhyX-
Available: hYp`PhyX- ~ testinggg (echo line)
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 05:33 PM
Hm... I'm stumped on this one... I can't test in a channel right now, but trying to test it locally, it seems to work fine.

Maybe someone will have an idea. If not, I'll be home in about 4 hours, so I can test it online then and see what I come up with.

For the moment, you could either disable the !$istok line by putting a semicolon (;) in front of that line and then /nick will work, or you can just not have it work with /nick for now. Note that if you disable that line, anyone who changes their nick would suddenly become available. That is what that line is supposed to prevent.

Sorry I can't find the problem with it right now.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 07/10/05 05:52 PM
Ok, When u got MSN, add me: Phyxius_UT@hotmail.com
Else, write a msg... check the /nick code & if u found it past it in here, i will msg back as soon as possible...
Posted By: Riamus2 Re: Need help with "!avail" thing... - 07/10/05 09:34 PM
Ok, found the problem. There was still one $chan in the /nick part. You didn't mention that it was giving an error about no such channel. smile

Code:
on *:nick: {
  if (!$istok($remove($chan(#yourchan).topic,44),$nick,32)) { return }
  var %topic = $remove($chan(#yourchan).topic,$nick $+ $chr(44),$nick)
  var %topic = $iif($right(%topic,1) == $chr(44),$left(%topic,-1),%topic)
  if ($gettok(%topic,2,58) == $null) { var %topic = Available: $newnick }
  else var %topic = %topic $+ , $newnick
  topic #yourchan %topic
}


Change all the #yourchans.
Posted By: FiberOPtics Re: Need help with "!avail" thing... - 08/10/05 04:32 AM
Quote:
Change all the #yourchans.


Just a small tip:

If you would specify at the beginning of the code: var %chan = #yourchan, and reference %chan subsequently, then he can just change the #yourchan there, and have it updated everywhere else automatically. In contrary, now one needs to look for all references of #yourchan and change them.

I know it's a detail, though it's actually quite handy.
Posted By: PhyxiuS Re: Need help with "!avail" thing... - 08/10/05 09:34 AM
Yeh, but i only need it for 1 channel... So, Riamus's script is ok for me... Now it's only in our Private Channel ... & uuhm, Thankx Riamus, the "nick" thingy is working now! Thankx wink
Posted By: FiberOPtics Re: Need help with "!avail" thing... - 08/10/05 01:16 PM
No you don't get what I'm saying. But that's ok.
Posted By: Riamus2 Re: Need help with "!avail" thing... - 10/10/05 02:37 PM
Good point, FiberOPtics. I have that on my major scripts. This one kind of evolved from a very small script to something larger, so I didn't think to add that to it. Oh well. As you said, it's just a detail. laugh
© mIRC Discussion Forums