mIRC Home    About    Download    Register    News    Help

Topic Options
#245059 - 10/04/14 04:27 AM Help with "on text" and variables
gavintrujillo Offline
Pikka bird

Registered: 09/04/14
Posts: 15
Here is my commands:

Quote:
on *:text:!setColor *:#:{
set %color. $+ $nick $2
msg $chan $nick Your favorite color $qt($2) was saved!
}
on *:text:!favColor *:#:{
var %color = %color. [ $+ [ $2 ] ]
if (%color != $null) {
msg $chan $nick $2's favorite color is %color $+ .
}
else {
msg $chan $nick $2 does't have a favorite color set yet.
}
}


The code works perfectly fine, except for one thing. You have to type !favcolor (then the username). I want to remove the requirement of putting a username in the command. Is it possible to make a command that pulls variables using the $nick that said the command instead of the person mentioned in the command?

Top
#245061 - 10/04/14 06:59 AM Re: Help with "on text" and variables [Re: gavintrujillo]
blessing Offline
Vogon poet

Registered: 03/04/14
Posts: 191
try change:

Code:
var %color = %color. [ $+ [ $2 ] ]

with:

Code:
var %color = %color. [ $+ [ $nick ] ]

Top
#245093 - 10/04/14 11:17 PM Re: Help with "on text" and variables [Re: blessing]
gavintrujillo Offline
Pikka bird

Registered: 09/04/14
Posts: 15
I've tried that already, just tried it again. Didn't work

EDIT: That just changes the part of the variable it grabs from
Quote:
%color.username green

so no matter the username you type after !favcolor, it will always show your username's color. The name is still required to be entered.


Edited by gavintrujillo (10/04/14 11:21 PM)

Top
#245095 - 10/04/14 11:58 PM Re: Help with "on text" and variables [Re: gavintrujillo]
Nillen Offline
Hoopy frood

Registered: 24/12/13
Posts: 779
Loc: Sweden
Code:
on *:text:!setcolor*:#:{
  set %color. [ $+ [ $nick ] ] $2
  msg # $nick $+ 's favorite color is now $2 $+ .
}

on *:text:!favcolor*:#:{
  if ($2 == $null) {
    if (%color. [ $+ [ $nick ] ] == $null) { msg # $nick doesn't have a favorite color set yet. | return }
    msg # $nick $+ 's favorite color is %color. [ $+ [ $nick ] ]
  }
  else { 
    if (%color. [ $+ [ $2 ] ] == $null) { msg # $2 doesn't have a favorite color set yet. | return }
    msg # $2 $+ 's favorite color is %color. [ $+ [ $2 ] ]
  }
}


I kind of combined it. Here's how you do it
!setcolor Green
Color is now Green
!favcolor
Your fav color is Green
!favcolor User
User's fav color is ...
_________________________
Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net

Top
#245100 - 11/04/14 03:09 AM Re: Help with "on text" and variables [Re: Nillen]
gavintrujillo Offline
Pikka bird

Registered: 09/04/14
Posts: 15
Thanks the code worked. I didn't really want help with that exact code, but I used your advice to finish my welcome bot:

Quote:
on *:text:!name*:#:{
if ((%floodname) || ($($+(%,floodname.,$nick),2))) { return }
set %floodname. $+ $nick On
set %name. [ $+ [ $nick ] ] $2
msg $chan $nick set their nickname to $2
}
on !*:join:#redhunterp:{
if ((%floodwelcome) || ($($+(%,floodwelcome.,$nick),2))) { return }
set -u21600 %floodwelcome. $+ $nick On
if ($2 == $null) {
if (%name. [ $+ [ $nick ] ] == $null) {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan $nick $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream $nick $+ ! Be welcome!
if (%welcome == 3) msg $chan $nick Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome $nick $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you $nick $+ , Welcome to the stream!
if (%welcome == 6) msg $chan $nick $+ , good to see you! Welcome to the stream!
}
else {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan %name. [ $+ [ $nick ] ] $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 3) msg $chan %name. [ $+ [ $nick ] ] Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you %name. [ $+ [ $nick ] ] $+ , Welcome to the stream!
if (%welcome == 6) msg $chan %name. [ $+ [ $nick ] ] $+ , good to see you! Welcome to the stream!
}
}
}


Thanks for the help grin

Top
#245101 - 11/04/14 03:55 AM Re: Help with "on text" and variables [Re: gavintrujillo]
blessing Offline
Vogon poet

Registered: 03/04/14
Posts: 191
My bad. I thought you just want to say !favcolor without username.
If you also want able to say !favcolor with username then it would be like this:

Code:
var %z = $iif($2,$2,$nick)
var %color = %color. [ $+ [ %z ] ]


Originally Posted By: gavintrujillo
I've tried that already, just tried it again. Didn't work

EDIT: That just changes the part of the variable it grabs from
Quote:
%color.username green

so no matter the username you type after !favcolor, it will always show your username's color. The name is still required to be entered.

Top
#245102 - 11/04/14 04:06 AM Re: Help with "on text" and variables [Re: gavintrujillo]
blessing Offline
Vogon poet

Registered: 03/04/14
Posts: 191
I dont think your code will work "perfectly".
Why did you think that join event has $2 in it?
$2 is always $null. CMIIW.

Another thing, if you join with newnick, how could you identify that is "you" with your old nick?
You have to identify it by checking their ip address.

Tips:
To make it more visible to you, dont use same welcome message. First you can use "Be Welcome", but for second part try use "Welcome Back" or else and see what happen.


Originally Posted By: gavintrujillo
Thanks the code worked. I didn't really want help with that exact code, but I used your advice to finish my welcome bot:

Quote:
on *:text:!name*:#:{
if ((%floodname) || ($($+(%,floodname.,$nick),2))) { return }
set %floodname. $+ $nick On
set %name. [ $+ [ $nick ] ] $2
msg $chan $nick set their nickname to $2
}
on !*:join:#redhunterp:{
if ((%floodwelcome) || ($($+(%,floodwelcome.,$nick),2))) { return }
set -u21600 %floodwelcome. $+ $nick On
if ($2 == $null) {
if (%name. [ $+ [ $nick ] ] == $null) {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan $nick $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream $nick $+ ! Be welcome!
if (%welcome == 3) msg $chan $nick Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome $nick $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you $nick $+ , Welcome to the stream!
if (%welcome == 6) msg $chan $nick $+ , good to see you! Welcome to the stream!
}
else {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan %name. [ $+ [ $nick ] ] $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 3) msg $chan %name. [ $+ [ $nick ] ] Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you %name. [ $+ [ $nick ] ] $+ , Welcome to the stream!
if (%welcome == 6) msg $chan %name. [ $+ [ $nick ] ] $+ , good to see you! Welcome to the stream!
}
}
}


Thanks for the help grin


Edited by blessing (11/04/14 04:23 AM)

Top
#245103 - 11/04/14 05:18 AM Re: Help with "on text" and variables [Re: blessing]
gavintrujillo Offline
Pikka bird

Registered: 09/04/14
Posts: 15
Thanks for pointing that out, I'm gonna make a distinct way of finding their username. Plus I check to see if their nickname is close to their user, so it's more secure. Other than that, the code has been working perfectly

EDIT: Sorry, I don't really understand what you are saying about the $2. Those $numbers are still extremely new to me because im very new to this, but the code still worked perfectly fine :p


Edited by gavintrujillo (11/04/14 05:34 AM)

Top
#245106 - 11/04/14 06:17 AM Re: Help with "on text" and variables [Re: gavintrujillo]
blessing Offline
Vogon poet

Registered: 03/04/14
Posts: 191
Try this:

- join with your nick "gavintrujillo"
- text !name gavin
- part from channel
- join back. bot will welcome you as gavin. Ok. thats cool.
- part from channel
- now CHANGE your nick to something else ex: newgavincool
- join back
- if it works perfectly, your bot should welcome you as gavin. not newgavincool.



Top
#245108 - 11/04/14 06:29 AM Re: Help with "on text" and variables [Re: blessing]
gavintrujillo Offline
Pikka bird

Registered: 09/04/14
Posts: 15
Yea, it completely works. If I try to change my already set nickname, it doesn't reply, and it doesn't change it. This works exactly how I want it to, because I will be able to permanently change anyone that changes their names to something inappropriate. This has been working for the past 4 hours perfectly with a constant 12 people in the channel. Thanks for the help smile

Top
#245109 - 11/04/14 07:11 AM Re: Help with "on text" and variables [Re: gavintrujillo]
blessing Offline
Vogon poet

Registered: 03/04/14
Posts: 191
It seems you are on irc.twitch.tv which is using registered username/nickname. Unregisterd username/nickname is not allowed. So that's okay.

About $2, you can just remove it from you code, because $2 is always $null on join event.

Code:
on !*:join:*:{
  if ((%floodwelcome) || ($($+(%,floodwelcome.,$nick),2))) { return }
  set -u21600 %floodwelcome. $+ $nick On
  if (%name. [ $+ [ $nick ] ] == $null) {
    var %welcome = $rand(1,6)
    if (%welcome == 1) msg $chan $nick $+ , Welcome to the stream! Be welcome!
    if (%welcome == 2) msg $chan Welcome to the stream $nick $+ ! Be welcome!
    if (%welcome == 3) msg $chan $nick Welcome! Be welcome!
    if (%welcome == 4) msg $chan Welcome $nick $+ ! Be welcome!
    if (%welcome == 5) msg $chan Good to see you $nick $+ , Welcome to the stream!
    if (%welcome == 6) msg $chan $nick $+ , good to see you! Welcome to the stream!
  }
  else {
    var %welcome = $rand(1,6)
    if (%welcome == 1) msg $chan %name. [ $+ [ $nick ] ] $+ , Welcome to the stream! Be welcome!
    if (%welcome == 2) msg $chan Welcome to the stream %name. [ $+ [ $nick ] ] $+ ! Be welcome!
    if (%welcome == 3) msg $chan %name. [ $+ [ $nick ] ] Welcome! Be welcome!
    if (%welcome == 4) msg $chan Welcome %name. [ $+ [ $nick ] ] $+ ! Be welcome!
    if (%welcome == 5) msg $chan Good to see you %name. [ $+ [ $nick ] ] $+ , Welcome to the stream!
    if (%welcome == 6) msg $chan %name. [ $+ [ $nick ] ] $+ , good to see you! Welcome to the stream!
  }
}

Top