mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2006
Posts: 27
Z
Zaephyr Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Aug 2006
Posts: 27
I'm trying to figure how this is written, but I keep getting blindsided at every turn, I think I'm probably doing it wrong. So I'm going to ask here.

First I'm trying to use the $nick to check the nick of the person triggering the on TEXT script. If it's Zaephyr I want the command to set the variable %g to equal Mistress, and if it is Darkhawk I want the command to set the variable %g to equal Master.

After that I put in the on *:Text part, with the trigger being: Would you do this:
below that I have the bots response as:

As you wish,

After the wish, I want the variable %g to come back into play and display either Master or Mistress, depending on which of the nicks was used to trigger the event. So if Zaephyr triggers it, the message will come on the channel as
As you wish, Mistress Zaephyr.
And if Darkhawk triggers it, the message will come on the channel as:
As you wish, Master Darkhawk.

I've tried looking around and testing various writings, pulled from the mIrc help file. But all I've managed to pull up are the words: As you wish, and either its blank, or several times with $var(%g) its just been 0. So how would I write the sentence to display the text value of a variable, instead of just a number, or nothing at all.

Immense thanks go out ahead of time to anyone that can show me what I'm doing wrong here.

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
To call a variable, there is no need for $var. $var is to look through the list of declaired variables, either by wildcard or matching. To get the value of %g, just use %g in the message.

I assume you have something such as the following:

Code:
on *:TEXT:*:#: {
  if ($nick == Zaephyr) var %g = Mistress
  else if ($nick == Darkhawk) var %g = Master

  ; the 'if' is to check for a gender existing
  ; meaning it found a name, and attached a gender in the %g variable
  if (%g) /msg $chan As you wish, %g $nick
}


It looks at the nickname that called the script. If it's one, it sets %g to Mistress, if it's another, it sets it to Master. Then, I have the script check for a gender (a name it recognizes and can specify a gender for), then outputs the message you wanted.


-KingTomato
Joined: Aug 2006
Posts: 27
Z
Zaephyr Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Aug 2006
Posts: 27
Would it be possible to write it so that the list of if this nick then this title is contained at the top of the script file, and each on text script can call the %g from that one at the top?

I plan on having a hefty dose of on texts and it would save me loads of typing if I could just put the list of nicks once in each script file and have the separate on text scripts call the variable from that.

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
How about this: wink

Code:
alias getGender {
  ; List of people who are 'masters'
  var %gender_master = Darkhawk
  ; List of people who are 'Mistresses'
  var %gender_mistress = Zaephyr
  
  if ($istok(%gender_master,$1,32)) return Master
  else if ($istok(%gender_mistress,$1,32)) return Mistress
}

on *:TEXT:!dummycmd1*:#: {
  var %g = $getGender($nick)
  
  /msg $chan %g $nick $+ , this is a dummy command!
}

on *:TEXT:!dummycmd2*:#: {
  var %g = $getGender($nick)
  
  /msg $nick This is another dummy command, %g $nick $+ !
}


Just add the var %g = $getGender($nick) to all your commands. Then, alter the alias to include all the names you want classified as mistresses and masters.


-KingTomato
Joined: May 2005
Posts: 449
Fjord artisan
Offline
Fjord artisan
Joined: May 2005
Posts: 449
If I understood you correctly, this might do what you want too. It assumes you have a text file called names.txt with the names of people and a space and then the "command" to perform.

Code:
on *:TEXT:*:#: {
  if ($read(names.txt,s,$1)) {
    var %line = $read(names.txt,$readn)
    var %maxtok = $numtok(%line,32)    
    msg $chan As you wish, $gettok(%line,2 - %maxtok,32) $gettok(%line,1,32)
  }
}


Again, I wasn't sure exactly what you wanted, but hope this helps. Actually, if what you're doing is calling them Master or Mistress, depending on the nick, then just have Master or Mistress be the second word in the text file, with the first word being the nick.

Last edited by bwr30060; 10/08/06 04:11 PM.
Joined: Aug 2006
Posts: 27
Z
Zaephyr Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Aug 2006
Posts: 27
King Tomato your's works perfectly, Thanks very much for the help with that. Now I can put in some serious implementation with my bot. Thanks again!

Joined: Aug 2006
Posts: 27
Z
Zaephyr Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Aug 2006
Posts: 27
I'm having a few problems with your script.
When I go and add a second name in.
Such as for %gender_master = Darkhawk
%gender_master = Umber
it stops working right.
It doesn't put Master up at all for one of the nicks, and does for the other.
I figured one way, by writing one as %gender_master and the other as %gender_masterU but is there a way to keep them using the same name and working correctly?

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
var %gender_master = Darkhawk Umber

Add names to the variable seperated by spaces.


-KingTomato
Joined: Aug 2006
Posts: 27
Z
Zaephyr Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Aug 2006
Posts: 27
Thanks, that did the trick. I also added in more of the variables, in the same formating. For the words he/she/his/him/her/hers for when those are needed. Thanks for your help.


Link Copied to Clipboard