mIRC Home    About    Download    Register    News    Help

Print Thread
#247024 19/07/14 07:32 AM
Joined: Jul 2014
Posts: 4
Z
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jul 2014
Posts: 4
I am sure you are all tired of seeing these types of posts but I cannot get it to work [code][/code]for the life of me. No idea why either.
Basically none of my viewers are gaining tokens. I can manually add them but my timer does not automatically add them. Aside from the obvious, I would in addition like to set it up so that the points can only be gained when the Twitch channel is live.

My code follows:


alias -l addTokens {
if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
var %topic $+($chan,.,$nick)
var %tokens $calc($readini(Tokens.ini,%topic,Tokens) + $1)
writeini -n Tokens.ini %topic Tokens %tokens
return %tokens
}

alias -l lookUpTokens {
var %topic $+($chan,.,$nick)
var %tokens $readini(Tokens.ini,%topic,Tokens)
return %tokens
}
alias doaddtokens {
if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
var %topic $+($1,.,$2)
var %tokens $calc($readini(Tokens.ini,%topic,Tokens) + $3)
writeini -n Tokens.ini %topic Tokens %tokens
echo -a Added tokens for %topic
}

alias doremtokens {
var %topic $+($1,.,$2)
remini -n Tokens.ini %topic Tokens
echo -a Removed tokens for %topic
}

on *:text:!tokens:#:{
if ((%floodtokens) || ($($+(%,floodtokens.,$nick),2))) { return }
set -u10 %floodtokens On
set -u30 %floodtokend. $+ $nick On
msg # $nick has $readini(Tokens.ini,$+(#,.,$nick),Tokens) total tokens.
}

on *:text:!tokencheck *:#:{
if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return }
set -u1 %floodcheck On
set -u5 %floodcheck. $+ $nick On
msg # $2 has $readini(Tokens.ini,$+(#,.,$2),Tokens) total tokens.
}

:#:{
if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return }
set -u1 %floodcheck On
set -u5 %floodcheck. $+ $nick On
msg # $2 has $readini(tokens.ini,$+(#,.,$2),Tokens) total tokens.
}

on $*:text:/!tokens (add|remove)/Si:#:{
if ($nick isop #) {
if ($0 < 3) { msg # Insufficient parameters: Use !tokens <add|remove> <user> [number] | return }
writeini -n Tokens.ini $+(#,.,$3) Tokens $calc($readini(Tokens.ini,$+(#,.,$3),Tokens) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
{ msg $chan $3 now has $readini(Tokens.ini,$+(#,.,$3),Tokens) total tokens. }
}
else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
$+(.timertokens.,#,.,$nick) 0 900 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}
on !*:part:#:$+(.timertokens.,#,.,$nick) off
alias -l add.pts {
writeini -n Tokens.ini $1 Tokens $calc($readini(Tokens.ini,$1,Tokens) + 1)

Joined: Jul 2014
Posts: 48
A
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
I'm not sure what you are doing here:
Code:
:#:{
if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return }
set -u1 %floodcheck On
set -u5 %floodcheck. $+ $nick On 
msg # $2 has $readini(tokens.ini,$+(#,.,$2),Tokens) total tokens. 
}


maybe fix/clear/comment that and check again if it's working or not. Otherwise I can give a deeper read into the code you posted, and see if there are any other questionable parts. A quick read-over only revealed that one section so far.



edit: just noticed that you are missing a closing bracket "}" at the very end. Not sure if you just missed over it when copy/paste, or if it's legit missing. Have you checked brackets already?

Last edited by AeonPsych; 19/07/14 08:01 AM.
Joined: Jul 2014
Posts: 4
Z
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jul 2014
Posts: 4
Thank you very much for looking at this. I don't know what that art was either! It shows up in my script in my back up as well. My guess it is a fragment from something I was working on that got caught up in the copy/paste I removed it in any case.
As to the closing bracket, yes, that was just left off.



alias -l addTokens {
if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
var %topic $+($chan,.,$nick)
var %tokens $calc($readini(Tokens.ini,%topic,Tokens) + $1)
writeini -n Tokens.ini %topic Tokens %tokens
return %tokens
}

alias -l lookUpTokens {
var %topic $+($chan,.,$nick)
var %tokens $readini(Tokens.ini,%topic,Tokens)
return %tokens
}
alias doaddtokens {
if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
var %topic $+($1,.,$2)
var %tokens $calc($readini(Tokens.ini,%topic,Tokens) + $3)
writeini -n Tokens.ini %topic Tokens %tokens
echo -a Added tokens for %topic
}

alias doremtokens {
var %topic $+($1,.,$2)
remini -n Tokens.ini %topic Tokens
echo -a Removed tokens for %topic
}

on *:text:!tokens:#:{
if ((%floodtokens) || ($($+(%,floodtokens.,$nick),2))) { return }
set -u10 %floodtokens On
set -u30 %floodtokend. $+ $nick On
msg # $nick has $readini(Tokens.ini,$+(#,.,$nick),Tokens) total tokens.
}

on *:text:!tokencheck *:#:{
if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return }
set -u1 %floodcheck On
set -u5 %floodcheck. $+ $nick On
msg # $2 has $readini(Tokens.ini,$+(#,.,$2),Tokens) total tokens.
}

on $*:text:/!tokens (add|remove)/Si:#:{
if ($nick isop #) {
if ($0 < 3) { msg # Insufficient parameters: Use !tokens <add|remove> <user> [number] | return }
writeini -n Tokens.ini $+(#,.,$3) Tokens $calc($readini(Tokens.ini,$+(#,.,$3),Tokens) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
{ msg $chan $3 now has $readini(Tokens.ini,$+(#,.,$3),Tokens) total tokens. }
}
else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
$+(.timertokens.,#,.,$nick) 0 900 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}
on !*:part:#:$+(.timertokens.,#,.,$nick) off
alias -l add.pts {
writeini -n Tokens.ini $1 Tokens $calc($readini(Tokens.ini,$1,Tokens) + 1)
}

Joined: Jul 2014
Posts: 4
Z
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jul 2014
Posts: 4
Not sure if it matters directly either, because it might be an issue with the fact that the timer/add tokens part of the script is not working, but the Tokens.ini was not created directly either; not until I manually added tokens to the bot.

Joined: Jul 2014
Posts: 48
A
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
Originally Posted By: Zorendier
Not sure if it matters directly either, because it might be an issue with the fact that the timer/add tokens part of the script is not working, but the Tokens.ini was not created directly either; not until I manually added tokens to the bot.


I had this exact same problem, too. I am trying to remember how I fixed it. Let me keep looking over your code in the meantime...
If the file isn't being created automatically, the timer won't work either. At least it was like that in my case. Not even if you manually create the file would it work.

Joined: Jul 2014
Posts: 48
A
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
ok. There is a typo in part of your code, but I don't believe it to be your problem (discussed after the break):
Code:
on *:text:!tokens:#:{
if ((%floodtokens) || ($($+(%,floodtokens.,$nick),2))) { return }
set -u10 %floodtokens On
set -u30 %floodtokend. $+ $nick On 
msg # $nick has $readini(Tokens.ini,$+(#,.,$nick),Tokens) total tokens. 
}


set -u30 %floodtokend. ---- change to %floodtokens.



I have a very leading suspect that your problem is you have another
Code:
on !*:join:#:{

command further up in your code. For instance, an on join that auto greets a newcomer? If you do have another on join, comment it out (disable it), and try the points system with a fresh start (no previous text file created). Have someone join your channel and wait till servers update for the join response to be acknowledged. Check points file and integrity of counter. I'd recommended lowering the timer frequency to a minute or a couple minutes, or increase the amount of points given per tick just for testing purposes so it is easy to tell right away when it is working.

If you don't have another "on join" command conflicting, I'm not completely sure on what it could be. Your code looks otherwise sound.



Side note:
Once your system starts working, the "on join" event will always instantly add whatever increment of points you have the timer set to add. If you don't want people to abuse joining and leaving to instantly gain points, change the add.pts (or tokens whatever) from
Code:
on !*:join:#:{
$+(.timertokens.,#,.,$nick) 0 900 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}


to add.<personal preference name here. I used "zero"> $+(#,.,$nick)
Obviously, you will now want to add a new alias for it. In my case:
Code:
alias -l add.zero {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 0)
}


where the + <number> at the end is a 0 instead of whatever increment the timer works with. Otherwise whenever someone joins the instantly get the increment. After the change, whenever someone joins, the instantly get + 0 points/tokens/w.e laugh




Hope the information I've presented helps you figure out your system!

-Aeon

Last edited by AeonPsych; 19/07/14 07:49 PM.
Joined: Jul 2014
Posts: 4
Z
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jul 2014
Posts: 4
Wow! Yes! I never even thought of my other "on join"! I feel like a dunce.

It works now, thank you so much. As far as the alias you suggested, I love it and actually just copied and pasted it to mine. My new code is (Just to make sure I got what you meant.):

alias -l addTokens {
if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
var %topic $+($chan,.,$nick)
var %tokens $calc($readini(Tokens.ini,%topic,Tokens) + $1)
writeini -n Tokens.ini %topic Tokens %tokens
return %tokens
}

alias -l lookUpTokens {
var %topic $+($chan,.,$nick)
var %tokens $readini(Tokens.ini,%topic,Tokens)
return %tokens
}
alias doaddtokens {
if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
var %topic $+($1,.,$2)
var %tokens $calc($readini(Tokens.ini,%topic,Tokens) + $3)
writeini -n Tokens.ini %topic Tokens %tokens
echo -a Added tokens for %topic
}

alias doremtokens {
var %topic $+($1,.,$2)
remini -n Tokens.ini %topic Tokens
echo -a Removed tokens for %topic
}

alias -l add.zero {
writeini -n Tokens.ini $1 Tokens $calc($readini(Tokens.ini,$1,Tokens) + 0)
}

on *:text:!tokens:#:{
if ((%floodtokens) || ($($+(%,floodtokens.,$nick),2))) { return }
set -u10 %floodtokens On
set -u30 %floodtokens. $+ $nick On
msg # $nick has $readini(Tokens.ini,$+(#,.,$nick),Tokens) total tokens.
}

on *:text:!tokencheck *:#:{
if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return }
set -u1 %floodcheck On
set -u5 %floodcheck. $+ $nick On
msg # $2 has $readini(Tokens.ini,$+(#,.,$2),Tokens) total tokens.
}

on $*:text:/!tokens (add|remove)/Si:#:{
if ($nick isop #) {
if ($0 < 3) { msg # Insufficient parameters: Use !tokens <add|remove> <user> [number] | return }
writeini -n Tokens.ini $+(#,.,$3) Tokens $calc($readini(Tokens.ini,$+(#,.,$3),Tokens) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
{ msg $chan $3 now has $readini(Tokens.ini,$+(#,.,$3),Tokens) total tokens. }
}
else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
$+(.timertokens.,#,.,$nick) 0 120 add.pts $+(#,.,$nick)
add.zero $+(#,.,$nick)
}
on !*:part:#:$+(.timertokens.,#,.,$nick) off
alias -l add.pts {
writeini -n Tokens.ini $1 Tokens $calc($readini(Tokens.ini,$1,Tokens) + 1)
{



My only other question was any ideas as to how to set this to only working when I am live? Short of disconnecting my bot when I leave.

I only studied one semester of code so far so I do not understand all of it, I do apologize.
Thank you so much!!!!

Last edited by Zorendier; 20/07/14 01:47 AM. Reason: Code
Joined: Jul 2014
Posts: 48
A
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
Haven't proof read your latest code, but looks good, and I am assuming it is infact good since you said it works... The triggers and code seem to be setup correctly upon skimming over it.



yea... I found out through setting up my chat bot that if you have 2 or more identical on* triggers, the first will take priority, and the second one gets ignored. I guess it treats on join as a 1 time event (which it should), but once it deals with that event once, it clears it, and continues through the code. Once reaching the next onjoin, the join event was cleared, so it won't even register that code. Again, same with other on*triggers, not just join.

Anyways, for a temp fix, in the on join trigger, I have it set to do everything I want it to do on join. So it does the points thing, sends a greeting, etc. Again, this is all done within 1 onjoin block of code.

Another thing I have figured out: With identical on triggers, if the first trigger isn't triggered, it will continue to the next.
For example, I have an ontext event that takes in virtually any text after a signal (like !), but it only will do something if the text is matched with words from a local file. If it doesn't match, it will say no match. If I put this at the beginning of my code, and say do a !codesd command where codesd wouldn't be a match within the file, but is in fact an actual command elsewhere, the bot would simply just return "not a valid match", but putting this at the end of my code, it would reach the actual !codesd command first, execute, then bypass the file search/match command.
Hard to explain, but hopefully you get the picture.



Anyways, good job on getting your code to work. I used to do java, c#, c++ a few years back, and stupid stuff like this always ruined my code... Missing bracket here, misplaced colon here, bad spacing here, conflicting events, but spelled/syntax correctly, so error checking wouldn't alert on anything. So frustrating sometimes, lol. My best friend became putting system messages (I guess in MIRC scripting they are just echos) in every part of my code to check where it was hanging, and what wasn't being executed when it should. Did the same thing here with mirc scripting, and was how I found out the problem we had.

Very inefficient, I know, but it gets the job done.
-Aeon


Link Copied to Clipboard