Jump to content

Variables Onjoin?


JOhnson

Recommended Posts

:help: iv asked this question in rumbaars and I also got the code from rumbaars so im a little embarrassed to ask in here and im :wallbash: as it seems im not gettting anywhere and I feel like <shot2> myself :lol: .. right the code his below

 

on *:JOIN:*:{
  .ctcpreply %targetnick TIME Welcome $nick hello

 

The code is in remote as a .mrc ... iv then put this into variables %targetnick

 

:lol: it gets better ... now this code works fine in spcn if the targetnick is a plain nick ... but hell if you try it with i.e ©Johnson© or even Johnson™ it wont work and to cap it all :shock: the code wont work with a plain or any other nick in koach or buzzen <bcry> ... any advice or nudge or even a good prod in the right direction would be gratefully received :D

Link to comment
Share on other sites

Guest Travis

JOhnson I see you use %targetnick, but I dont see you setting target nick. Regardless it is pointless to use a variable in an event to return $nick. Just use $nick. :)

Link to comment
Share on other sites

Guest X-Fusion

Like I told you in the chat, your not setting the target nick...

 

on *:JOIN:*:{
   var %targetnick $nick
  .ctcpreply %targetnick TIME Welcome $nick hello
}

 

And even then, it's really a waste of code when you can do what Foreverurs and Travis posted.

Link to comment
Share on other sites

:oops: right fellas I am a bit confused here ... let me try and explain what im looking for :D say X-Fusion you come into my chatroom and I just want you to see a private message from me via my script as a ctcpreply surely Iv got to target your nick i.e %targetnick X-Fusion or everyone will see my message to you. Thank you for your replies and help and X my server went down while I was talking to you in the chatroom sz mate :D
Link to comment
Share on other sites

Guest X-Fusion

No, you don't have to target it. That's what $nick does. $nick is the name your targeting in your event (in this case, an onjoin event). There's no need to set a variable for it.

Link to comment
Share on other sites

it all depends on where it's placed as to what it will do.. if nick is in the target place as in ctcpreply $nick it will send to that nickname.. if you had ctcpreply $nick $nick hey it would target the nickname and say the nickname in the reply.

 

This is the concept I tend to follow

 

If i want to create a var for use only while the snippet is processing like a while loop then use a temp variable

 

example to check what dialogs you currently have open

 

/checkdialogs {
      var %d 1
      while ($dialog(%d)) {
        echo -a $dialog(%d)
        inc %d
      }
    }

 

now %d is a variable set, but it only lasts until the snippet is done processing. You do not have to use any unset. Once the process is over the var is gone.

 

You can also use an unset command on a timer

 

set -u5 %blah on

 

This will set the variable %blah to on for a period of 5 seconds and then auto unset it. Reasoning behind using temp vars and timed unsets is to keep unneeded variables from accumulating in your variables file.

 

Only set a non temp, non timed unset variable if you plan on using the variable for prolonged periods of time. I mainly use variables for settings or information I wish to keep for long periods of time. There are other methods such as hash tables and ini files that can do the same thing but I would first get comfortable with variables before i moved on to those other types.

 

You won't have to set variables for things like $chan or $nick in an event unless you plan on carrying them over to something else. If the event supports the identifier you don't have to set a variable.

 

for example

on *:JOIN:#:{
    set %nickname $nick
    set %channelname $chan
    ctcpreply %nickname Hey %nickname welcome to %channelname
    unset %nickname, %channelname
    }

 

is more easily done with

on *:JOIN:#:{
    ctcpreply $nick Hey $nick welcome to $chan
    }

 

The code doesn't work on buzzen because buzzen does not support ctcp like that so it would be a bit useless.

Koach does have support for ctcp so you shouldn't have problems there

 

Another thing to consider is on join commands like that, is to always add in flood protection. If you had a mass join on the room it would play havoc and most likely disconnect you without some form of flood protection.

 

a simple auto unsetting variable would be a good idea.

 

example

on *:JOIN:#:{
  inc -u3 %welcome.flood
  if (%welcome.flood == 1) && ($nick != $me) { ctcpreply $nick Hey $nick welcome to $chan }
   }

 

Basically what it is doing is each time there is a join it sets an increasing number to the variable %welcome.flood

 

Peter joins room

%welcome.flood is set to 1

Jan joins room

%welcome.flood is set to 2

and so on

but the variable will unset after 3 seconds defined by the -u3

so it will start the count back over after 3 seconds

so if more than 1 user joins in a 3 sec period it will not ctcpreply the nick

:note the unset time can be lowered in a very active room

 

As with most anything in scripting you can achieve the same thing in many different ways. I've laid out the previous examples in a way I hope is very easily understandable. If you have any questions just ask.

Link to comment
Share on other sites

:lmaojump: hell err0r what would we do without you fella ... iv read your reply and im over the moon with the way you have explained it lol iv not took it all in but most of it and I will keep reading it until I do :D ... I understand now that ctcpreply doesnt work in buzzen thats not a problem lol ... what can I say but as always err0r nais take = thank you :D
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...