mIRC Home    About    Download    Register    News    Help

Print Thread
Announce on goal script? #251829 05/03/15 08:15 PM
Joined: Dec 2014
Posts: 26
A
Athenlayjoshr Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Dec 2014
Posts: 26
Anyone got a script were basicly there is a .txt called goals.txt
in that txt there is
-------
50
100
125
150
-------
And when a the channel the bot is connected to reaches one of those numbers with players it will say
-------
First Msg: We have reached 50 players
Second Msg: Thank you everyone
-------
If anyone has this that would be cool if you could send me it.

Re: Announce on goal script? [Re: Athenlayjoshr] #251831 05/03/15 09:21 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
By players, do you mean channel users?
This would be relatively simple to do. Make a goal.txt file, you can hook up an alias on either the join event or a simple timer.
The alias will check how many users there are in the channel, using $nick(#,0)
Compare that value to the .txt file's first line using $read(goals.txt,tn,1) - if it's > that, check the next line until the matches stop. Then use that value in your message(s).

P.S. A tip would be to use a while loop to inc a %variable that can be called for the lines in the text file.

Last edited by Nillen; 05/03/15 09:24 PM.

Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Announce on goal script? [Re: Nillen] #251847 06/03/15 07:47 PM
Joined: Dec 2014
Posts: 26
A
Athenlayjoshr Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Dec 2014
Posts: 26
I'm quite new to mIRC so i don't really know how i would make a script like that smirk

Re: Announce on goal script? [Re: Athenlayjoshr] #251855 06/03/15 09:52 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Well, let's work on it together then, shall we?

Like I mentioned, you can either hook it up on a join event or as a timer, but that's literally the last step. We can decide that later, let's just create the alias first.
To create an alias in a remote section you type
Code:
alias NameOfAlias {
;code goes here
;Read about this on /help aliases
}
We can later call this alias using a timer or the join event.

But one thing is certain, we'll need to know what channel you're using. We want to send the channel to the alias. As you should know after readin the help files, sending something to an alias will make that value translate into $1.
So it would look something like this.
Code:
alias NameOfAlias { 
var %channel $1
var %users $nick(%channel,0)
;$nick(%channel,0) will translate into the number of users on the channel specified.
;Read more about that on /help $nick - The second one.
}

All right, we're off to a good start. Now we have the users on the specified channel. Let's check and compare that to the valeus of goals.txt.
The code should look something like this with that in mind.
Code:
alias NameOfAlias {
var %channel $1
var %users $nick(%channel,0)
var %file goals.txt
var %read $read(%file,tn,1)
}
That doesn't exactly do what we want though. Cause that only gives us the first line, and we still don't have an if statement checking for the values if they match or not...

How do you think we should continue?


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Announce on goal script? [Re: Nillen] #251928 09/03/15 10:28 PM
Joined: Dec 2014
Posts: 26
A
Athenlayjoshr Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Dec 2014
Posts: 26
Maybe setting a timer to check the users in the channel every minuet?
and if $nick(%channel,0) = a number in goals.txt
msg $chan $chan has reached 50 viewers!

Last edited by Athenlayjoshr; 09/03/15 10:30 PM.
Re: Announce on goal script? [Re: Athenlayjoshr] #251929 09/03/15 10:33 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Fair enough, you want to use a timer.
When do you start the timer?

And how does the alias know which channel it's supposed to check for?
Try creating an event that starts a timer. The timer should use the alias "NameOfAlias" to check for users in the channel you want.
We'll work on the If statement after that step is complete.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Announce on goal script? [Re: Nillen] #251930 09/03/15 10:42 PM
Joined: Dec 2014
Posts: 26
A
Athenlayjoshr Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Dec 2014
Posts: 26
on *:JOIN:#:
timer $+ 0 60 ChanJoin <-- Alias name. (then what it would do but i don't know this bit)

I don't know how to set a alias to a timer i think it might be that.

Last edited by Athenlayjoshr; 09/03/15 10:43 PM.
Re: Announce on goal script? [Re: Athenlayjoshr] #251931 09/03/15 11:03 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Well, that works. But I wouldn't suggest it as it is not optimal.
The way you scripted it right now would re-start the timer for every person joining the channel.
A reccomended way to do it is to start it on your join event. Such as:
Code:
on *:join:#: { 
if ($nick == $me) {
.timerUserCheck. $+ $chan 0 60 NameOfAlias $chan
}
}
As you know, after reading the help files of aliases - " /Help Aliases " - the first word you send to an alias will be treated as $1.
So sending " NameOfAlias $chan " will trigger the Alias, and send $chan (#channelname) as the first word.

When this reaches your alias, it will use "var %channel $1" which means "%channel" will now be the same as $chan which was sent from the Join event.

Now your code should look something like this:
Code:
on *:join:#: { 
if ($nick == $me) {
.timerUserCheck. $+ $chan 0 60 NameOfAlias $chan
}
}

alias NameOfAlias {
var %channel $1
var %users $nick(%channel,0)
var %file goals.txt
}
Let's keep working with this. You now have the values of all users in the channel every 60 seconds. You can try this out by adding this line to the code at the bottom.
Code:
echo %channel The user number of this channel are now: %users


But that's not your end-goal is it? No, you want to check it with the file you've added. You'll need to read up on While loops for this to work. Type " /help while loops " in the editbox and see if that makes sense. You can always try creating a custom alias as well and see how it works in actuality.

Now, let's proceed with this new knowledge.
Code:
on *:join:#: { 
if ($nick == $me) {
.timerUserCheck. $+ $chan 0 60 NameOfAlias $chan
}
}

alias NameOfAlias {
var %channel $1
var %users $nick(%channel,0)
var %file goals.txt
var %i 1
;%i is now = 1
var %lines $lines(%file)
;Now we know how many lines there are in %file (goals.txt)
;Let's make a while loop for how as many lines there are in the file.
while (%i <= %lines) {
;All right, we're in! 
var %line $read(%file,tn,%i) 
;This is specified to read the file's lines. Note that I'm using %i instead of 
;1 or something. This is cause we're going to increment %i and make it bigger.

;Let's proceed and make an if statement inside the loop
if (%users < %line) { 
;If the amount of users are under the amount presented in the file we want to stop looping
break
}
else { var %goal %line }
;If you actually are over the %line with %users, we create a new variable 
;called %goal which will be the same as %line that you did overcome.
inc %i
;now we increased it, so when this loop is "over" it's gonna re-do the loop as long
;as %i is not over %lines

}
;%line is at this point set to the goal you didn't yet reach
;%goal is set to the highest goal you reached.
;If you have 33 people and the goals are 10,20,30,40 - %goal will now be 30

;So now you just need to check if you actually reached a goal.
if (%goal) { msg %channel We reached the %goal goal! We now have %users total users! - The next goal is: %line $+ ! }
}


Now, make sure you read all the help files I've told you to read, and make sure you take the time to try and understand what's happening. That's the only way you'll ever learn to do these things by yourself.

Last edited by Nillen; 09/03/15 11:08 PM. Reason: Fixed timername

Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net