mIRC Homepage
Posted By: FuryRang Some help for noob. Creating a command. - 09/02/15 05:54 PM
Hi guys.
I just tryed this program and it works well. So I made the simple commands for my personal twitch bot. Like !fb, !twitter etc. That gives a text after command in chat.
So i dont understand how can i make the following options:

  • !command <option> I need to put the <option> into a global variable, how can i do this?
  • How to create arrays(is it possible?).


I'll be very greatfull if someone can help me with my problems.
Thanks.
Would be nice to explain more about how and what you want the <option> to be like. Is it about opening Twitter page, or posting to Twitter, or something else? Maybe you can post a few hypothetical commands you would type.
Posted By: FuryRang Re: Some help for noob. Creating a command. - 09/02/15 06:36 PM
I need to do a simple counter.
Example:
user writting: !command string;
And i'm creating(if not exists) or inc() variable string as integer value;
I'm afraid i still don't understand smirk

U want to count to a certain number? Like:
Input: !count 5
Output: 1, 2, 3, 4, 5

U want to count seconds elapsed?
Input: !count
Output: Seconds 5,4,3,2,1....

Btw, inc is a command, so u don't need () next to it smile
Posted By: FuryRang Re: Some help for noob. Creating a command. - 09/02/15 07:34 PM
Nop, i want to count number of times which used !command with this <option>
Code:
on *:text:!command *:#:{
  var %cmd = $gettok($1-,2-,32)
  set %command. $+ $remove(%cmd,$chr(32)) %cmd
}


!command take me to the stars

that would create a global variable %command.takemetothestars
Posted By: FuryRang Re: Some help for noob. Creating a command. - 09/02/15 08:06 PM
Thanks, i'll try wink

How can I write the value into chat?
/say %command.takemetothestars


And, since you originally wanted to count the times that was said:

Code:
on *:text:!command *:#:{
  var %cmd = $gettok($1-,2-,32)
  if (!%command. $+ $remove(%cmd,$chr(32))) {
    set %command. $+ $remove(%cmd,$chr(32)) %cmd
  }
  else {
    inc %command. $+ $remove(%cmd,$chr(32)) $+ .times
  }
}


In this case %command.takemetothestars holds the option,
and the %command.takemetothestars.times the number of times used.
Posted By: FuryRang Re: Some help for noob. Creating a command. - 10/02/15 12:27 PM
Thanks mate, it works well)
All the counts are working, i got the variables with each value.
But when i'm trying to put the value of %command.<option>.times into chat, it's writing sth like this: <option>.times

Code:
on *:text:!command *:#:{
  var %cmd = $gettok($1-,2-,32)
  if (!%command. $+ $remove(%cmd,$chr(32))) {
    set %command. $+ $remove(%cmd,$chr(32)) %cmd
  }
  else {
    inc %command. $+ $remove(%cmd,$chr(32)) $+ .times
  }

  msg $chan %command. $+ $remove(%cmd,$chr(32)) $+ .times

}

Posted By: FuryRang Re: Some help for noob. Creating a command. - 10/02/15 01:51 PM
Ah, and onemore question.
Is there foreach() or for(int %a=1){} function?
No, you need to do everything through while loops.
Posted By: FuryRang Re: Some help for noob. Creating a command. - 10/02/15 02:10 PM
Originally Posted By: Loki12583
No, you need to do everything through while loops.
Found that sleep
So, why command writning in chat <option>.times instead off value :C
In vars file all the values a created and increasing.
Yes, u are right. It's because i forgot to use brackets. Haven't used dynamics for a long time hehe. It's also better to use $null instead of !


Code:
on *:text:!command *:#:{
  var %cmd = $gettok($1-,2-,32)
  if (%command. $+ $remove(%cmd,$chr(32)) == $null) {
    set %command. $+ $remove(%cmd,$chr(32)) %cmd
  }
  else {
    inc %command. $+ $remove(%cmd,$chr(32)) $+ .times
  }

  msg $chan %command. [ $+ [ $remove(%cmd,$chr(32)) $+ .times ] ]

}
© mIRC Discussion Forums