mIRC Homepage
Posted By: R4nk3d Var and If - 04/05/08 04:19 AM
http://www.paste.mircscripting.info/index.php?id=2764

Whats wrong with that? Why wont it work.
Posted By: AWEstun Re: Var and If - 04/05/08 04:24 AM
why not just use $nick ison $chan ?
Posted By: R4nk3d Re: Var and If - 04/05/08 04:48 AM
Alright. Ill try that. Im not sure if itll work for what im trying.
Posted By: genius_at_work Re: Var and If - 04/05/08 05:07 AM
Are you sure %nick is being set to what you are expecting? Try adding this debug line:

/echo -s nick: %nick

Assuming the variable is being set correctly (ie to a nickname who is on the channel where the text is received), the code should work as it is written.

-genius_at_work
Posted By: AWEstun Re: Var and If - 04/05/08 05:16 AM
echo is your best friend when scripting !!!
Posted By: R4nk3d Re: Var and If - 04/05/08 05:24 AM
ok. thanks. ill try both when i can.
Posted By: Joe_Dean Re: Var and If - 04/05/08 05:49 AM
R4nk3d is a scripting noob. :P

We run a gaming server. Basically everything that is said from inside the game is echoed into an IRC channel. The ingame players aren't actually in the channel - there's one bot that echos everything, e.g.:

Quote:

(01:43) · [KUMB] · Aaron_butche(1) - Hi!
(01:43) · [KUMB] · Scion(4) - Hello smile
(01:43) · [KUMB] · Joe_Dean(3) - Welcome!!


The %nick var is used to extract the actual name from the (*) (this is the players ID ingame). We don't want to include their ID's, so the %nick var gets everything until it hits the first occurrence of '(', then stops there.

Now, if %nick is also inside the IRC channel and not just ingame, I want the script to allow use of the script by this user.

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

So if a player ingame types !blah, the script must check to see if that name is also in the IRC channel (by using: if (%nick ison $chan) {

This isn't added into the script that R4nk3d linked, but the plan is to restrict the use of the script to voiced users. So:

Quote:
if (%nick ison $chan) && (%nick isvoice $chan) {


But that's just the next step of the script - I need to know first how to use vars in an IF statement.
Posted By: Joe_Dean Re: Var and If - 04/05/08 06:01 AM
Here's a small script I made to autoban when a player ingame advertises an IP & Port. Perhaps it'll give you an idea of how I make the scripts interact with users inside the gaming server.

http://www.paste.mircscripting.info/index.php?id=2766

Basically does this:
Quote:

[KUMB] · Kim_Annabeth(1) - 12.34.56.78:1234
Naed · !say Advertising is prohibited on this server, Kim_Annabeth.
Naed · !ban Kim_Annabeth
[KUMB] · Naed(IRC) - Advertising is prohibited on this server, Kim_Annabeth.
[KUMB] · ***(ADMIN BAN)*** player Kim_Annabeth has been banned from the gaming server.


Basically, Kim_Annabeth advertises an IP ingame. Then, Naed (the IRC bot I'm scripting) warns the player then bans them.

!say is just a command to echo stuff from IRC into the game
!ban is an IRC command that OPs use to ban players ingame via IRC.

Where it says ***(ADMIN BAN)*** is what happens in the server; it shows the player being banned ingame.
Posted By: genius_at_work Re: Var and If - 04/05/08 06:03 AM
Try this instead:

var %nick = $gettok($1,1,40)

By what you are describing, you will need to store the names of the users who are in both locations, and then use that to allow them access to the script commands.

-genius_at_work
Posted By: Joe_Dean Re: Var and If - 04/05/08 06:16 AM
That does nothing, -at all-.

I'm not the best with scripting either, I'm still in my learning stages. Could you explain what that does, exactly? The help file confuses me. :P

If this helps: the ID from the players name needs to be extracted from the actual name. If I were to just use $1 (look above, this is the playername followed by the ID (*) e.g. Kim_Annabeth(4), this would return the entire name & ID, Kim_Annabeth(4). And obviously that name isn't going to be in the IRC channel, however Kim_Annabeth would be.

I can't take away the IDs - it's a part of the gaming server, so the (*) MUST be extracted for this script to work.
Posted By: genius_at_work Re: Var and If - 04/05/08 05:36 PM
This:

var %nick = $gettok($1,1,40)

is a replacement for this:

var %nick $mid($1,1,$calc($pos($1,$chr(40),1) - 1))

nothing more.

-genius_at_work
Posted By: Joe_Dean Re: Var and If - 05/05/08 01:29 AM
Yeah, sorry, it didn't work before simply because I had a mistake in the script (not pertaining to the $gettok).

Anyways, this works, sorta. It doesn't work properly, and I can't figure out what is going on.

Quote:

[KUMB] · Joe_Dean(0) - !blahtest
&Naed · no
~Joe_Dean · !blahtest
&Naed · no
~Joe_Dean · !say !blahtest
&Naed · no
[KUMB] · Joe_Dean(IRC) !blahtest
&Naed · yes


So basically:

- If I'm inside the gaming server and I type "!blahtest", the bot says no (no meaning, not in the channel).
- If I'm in the IRC channel and type "!blahtest", the bot says no.
- HOWEVER, if I'm in the IRC channel and echo "!blahtest" into the gaming server, the bot says yes AND no.

I don't understand...
Posted By: Joe_Dean Re: Var and If - 05/05/08 01:31 AM
Ohh, could it be because when I say something inside the gaming server, my name has a number at the end (Joe_Dean(0)), but if I'm echoing into the gaming server via the IRC channel, my name has letters at the end (Joe_Dean(IRC)) ?
Posted By: Joe_Dean Re: Var and If - 07/05/08 03:49 AM
*bump*
Posted By: Joe_Dean Re: Var and If - 08/05/08 09:28 PM
*sigh*

*bump again*
Posted By: starbucks_mafia Re: Var and If - 09/05/08 03:19 AM
OK let's clarify what you want:

You want a mIRC script that will respond to a peice of text with the format "somenick(id) - !blahtest" and check if that user (minus the (id) portion) is on the current IRC channel?

Code:
on *:TEXT:& - !blahtest:#:{
  var %nick = $gettok($1, 1, 40)
  if (%nick ison $chan) {
      something here
  }
}


That should work. If it doesn't then either there's another script interfering or there's something else going on you haven't mentioned.
Posted By: Joe_Dean Re: Var and If - 09/05/08 05:18 AM
Code:
on *:TEXT:& - !blahtest:#:{
  var %nick = $gettok($1, 1, 40)
  if (%nick ison $chan) {
      msg $chan !say In the IRC
  }
  else {
    msg $chan !say Not in IRC
  }
}


Quote:

[KUMB] · Joe_Dean(3) - !blahtest
&Naed · !say Not in IRC
[KUMB] · Naed(IRC) Not in IRC
Posted By: Joe_Dean Re: Var and If - 09/05/08 05:24 AM
http://www.lvrcr.com/ircscreen.png

The green text is me.

EDIT: Notice I am in the channel.
Posted By: Joe_Dean Re: Var and If - 09/05/08 05:29 AM
ROFL, I'm such a noob. XD

Code:
on *:TEXT:& - !blahtest:#:{
  var %nick = $gettok($1, 1, 40)
  if ($strip(%nick) ison $chan) {
      msg $chan !say In the IRC
  }
  else {
    msg $chan !say Not in IRC
  }
}


My name in the gaming server is in bold and my name on IRC isn't. :P
© mIRC Discussion Forums