mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#259255 23/10/16 05:06 PM
Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
Hello!

I'm hoping that anyone can help me creating a script for adding currencies automatically.

The idea is each new subscriber will receive 100 bonus gold. Additionally subscribers will receive bonus gold at each 3 month milestone. This bonus gold will increase with subscription length.

For example;
3 month sub = 500 gold
6 month sub = 500 + 100 gold
9 month sub = 500 + 200 gold
12 month sub = 500 + 300 gold
And so on!

Script needs to be sending message in Twitch chat, !bonus username 500

Thank you whoever helping me!

Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
Posts: 133
Easiest way

*** UNTESTED ***

Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key == ROOMID) && (resub isin $msgtags) {
    if ($msgtags(msg-param-months).key == 3) {
      msg $1 !bonus $msgtags(display-name).key 500
    }
	elseif ($msgtags(msg-param-months).key == 6) {
      msg $1 !bonus $msgtags(display-name).key 600
    }
	elseif ($msgtags(msg-param-months).key == 9) {
      msg $1 !bonus $msgtags(display-name).key 700
    }	  
	elseif ($msgtags(msg-param-months).key == 12) {
      msg $1 !bonus $msgtags(display-name).key 800
    }	 	
  }
}


twitter @keyeslol
Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
Hey @keyeslol

It's good to see you helping me. laugh Where shall I put the channel name? I assume that ROOMID should be replaced as the channel name?

Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
Posts: 133
you can get your roomid by running this command:

Code:
//window -e @raw | debug @raw


In there you'll see room-id. You don't need to reference your channel name at all, as that is handled by $1.


twitter @keyeslol
Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
Oh, I see. Thanks. And now, I need to replace ROOMID with the ID I got from that command?

Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
Posts: 133
Yes.


twitter @keyeslol
Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34


Well, it did not go so well.

Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key == 12665) && (resub isin $msgtags) {
    if ($msgtags(msg-param-months).key == 3) {
      msg $1 !bonus $msgtags(display-name).key 500
    }
    	elseif ($msgtags(msg-param-months).key == 6) {
      msg $1 !bonus $msgtags(display-name).key 600
    }
    	elseif ($msgtags(msg-param-months).key == 9) {
      msg $1 !bonus $msgtags(display-name).key 700
      }	  
      	elseif ($msgtags(msg-param-months).key == 12) {
        msg $1 !bonus $msgtags(display-name).key 800
      }
      elseif ($msgtags(msg-param-months).key == 15) {
        msg $1 !bonus $msgtags(display-name).key 900
      }  
      elseif ($msgtags(msg-param-months).key == 18) {
        msg $1 !bonus $msgtags(display-name).key 1000
      } 
      elseif ($msgtags(msg-param-months).key == 21) {
        msg $1 !bonus $msgtags(display-name).key 1100
      }  
      elseif ($msgtags(msg-param-months).key == 24) {
        msg $1 !bonus $msgtags(display-name).key 1200
      } 
      elseif ($msgtags(msg-param-months).key == 27) {
        msg $1 !bonus $msgtags(display-name).key 1300
      } 
      elseif ($msgtags(msg-param-months).key == 30) {
        msg $1 !bonus $msgtags(display-name).key 1400
      }
      elseif ($msgtags(msg-param-months).key == 33) {
        msg $1 !bonus $msgtags(display-name).key 1500
      }
      elseif ($msgtags(msg-param-months).key == 36) {
        msg $1 !bonus $msgtags(display-name).key 1700
      } 
      elseif ($msgtags(msg-param-months).key == 39) {
        msg $1 !bonus $msgtags(display-name).key 1800
      } 
      elseif ($msgtags(msg-param-months).key == 42) {
        msg $1 !bonus $msgtags(display-name).key 1900
      } 
      elseif ($msgtags(msg-param-months).key == 45) {
        msg $1 !bonus $msgtags(display-name).key 2000
      } 
      elseif ($msgtags(msg-param-months).key == 48) {
        msg $1 !bonus $msgtags(display-name).key 2100
      } 
      elseif ($msgtags(msg-param-months).key == 51) {
        msg $1 !bonus $msgtags(display-name).key 2200
      } 
    }
  }

Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
Posts: 133
I told you it was untested lol. It also looks like you are missing a closing bracket as well.

Parenthesis are important, try this.

Code:
raw USERNOTICE:*:{
  if (($msgtags(room-id).key == 12665) && (resub isin $msgtags)) {
    if (($msgtags(msg-param-months).key) == 3) {
      msg $1 !bonus $msgtags(display-name).key 500
    }
    	elseif (($msgtags(msg-param-months).key) == 6) {
      msg $1 !bonus $msgtags(display-name).key 600
    }
    	elseif (($msgtags(msg-param-months).key) == 9) {
      msg $1 !bonus $msgtags(display-name).key 700
      }	  
      	elseif (($msgtags(msg-param-months).key) == 12) {
        msg $1 !bonus $msgtags(display-name).key 800
      }
      elseif (($msgtags(msg-param-months).key) == 15) {
        msg $1 !bonus $msgtags(display-name).key 900
      }  
      elseif (($msgtags(msg-param-months).key) == 18) {
        msg $1 !bonus $msgtags(display-name).key 1000
      } 
      elseif (($msgtags(msg-param-months).key) == 21) {
        msg $1 !bonus $msgtags(display-name).key 1100
      }  
      elseif (($msgtags(msg-param-months).key) == 24) {
        msg $1 !bonus $msgtags(display-name).key 1200
      } 
      elseif (($msgtags(msg-param-months).key) == 27) {
        msg $1 !bonus $msgtags(display-name).key 1300
      } 
      elseif (($msgtags(msg-param-months).key) == 30) {
        msg $1 !bonus $msgtags(display-name).key 1400
      }
      elseif (($msgtags(msg-param-months).key) == 33) {
        msg $1 !bonus $msgtags(display-name).key 1500
      }
      elseif (($msgtags(msg-param-months).key) == 36) {
        msg $1 !bonus $msgtags(display-name).key 1700
      } 
      elseif (($msgtags(msg-param-months).key) == 39) {
        msg $1 !bonus $msgtags(display-name).key 1800
      } 
      elseif (($msgtags(msg-param-months).key) == 42) {
        msg $1 !bonus $msgtags(display-name).key 1900
      } 
      elseif (($msgtags(msg-param-months).key) == 45) {
        msg $1 !bonus $msgtags(display-name).key 2000
      } 
      elseif (($msgtags(msg-param-months).key) == 48) {
        msg $1 !bonus $msgtags(display-name).key 2100
      } 
      elseif (($msgtags(msg-param-months).key) == 51) {
        msg $1 !bonus $msgtags(display-name).key 2200
      } 
    }
  }
}


twitter @keyeslol
Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
Nope.. Streamer getting mad by this spams. XD


Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
Any update on this? I have removed one extra closing bracket, I think this is the one which caused it.

Code:
raw USERNOTICE:*:{
  if (($msgtags(room-id).key == 12665) && (resub isin $msgtags)) {
    if (($msgtags(msg-param-months).key) == 3) {
      msg $1 !bonus $msgtags(display-name).key 500
    }
    	elseif (($msgtags(msg-param-months).key) == 6) {
      msg $1 !bonus $msgtags(display-name).key 600
    }
    	elseif (($msgtags(msg-param-months).key) == 9) {
      msg $1 !bonus $msgtags(display-name).key 700
      }	  
      	elseif (($msgtags(msg-param-months).key) == 12) {
        msg $1 !bonus $msgtags(display-name).key 800
      }
      elseif (($msgtags(msg-param-months).key) == 15) {
        msg $1 !bonus $msgtags(display-name).key 900
      }  
      elseif (($msgtags(msg-param-months).key) == 18) {
        msg $1 !bonus $msgtags(display-name).key 1000
      } 
      elseif (($msgtags(msg-param-months).key) == 21) {
        msg $1 !bonus $msgtags(display-name).key 1100
      }  
      elseif (($msgtags(msg-param-months).key) == 24) {
        msg $1 !bonus $msgtags(display-name).key 1200
      } 
      elseif (($msgtags(msg-param-months).key) == 27) {
        msg $1 !bonus $msgtags(display-name).key 1300
      } 
      elseif (($msgtags(msg-param-months).key) == 30) {
        msg $1 !bonus $msgtags(display-name).key 1400
      }
      elseif (($msgtags(msg-param-months).key) == 33) {
        msg $1 !bonus $msgtags(display-name).key 1500
      }
      elseif (($msgtags(msg-param-months).key) == 36) {
        msg $1 !bonus $msgtags(display-name).key 1700
      } 
      elseif (($msgtags(msg-param-months).key) == 39) {
        msg $1 !bonus $msgtags(display-name).key 1800
      } 
      elseif (($msgtags(msg-param-months).key) == 42) {
        msg $1 !bonus $msgtags(display-name).key 1900
      } 
      elseif (($msgtags(msg-param-months).key) == 45) {
        msg $1 !bonus $msgtags(display-name).key 2000
      } 
      elseif (($msgtags(msg-param-months).key) == 48) {
        msg $1 !bonus $msgtags(display-name).key 2100
      } 
      elseif (($msgtags(msg-param-months).key) == 51) {
        msg $1 !bonus $msgtags(display-name).key 2200
      } 
    }
  }

Joined: Oct 2016
Posts: 14
F
Pikka bird
Offline
Pikka bird
F
Joined: Oct 2016
Posts: 14
Code:
    if (($msgtags(msg-param-months).key) == 3) {
      msg $1 !bonus $msgtags(display-name).key 500
    }

So for each 3rd month add another 100 .. then you should be able to do this instead of the repeating row of ifs:
Code:
   msg $1 !bonus $msgtags(display-name).key $calc( 500 + 100 * ( $msgtags(msg-param-months).key % 3 ) )


so:
Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key == 12665) && (resub isin $msgtags) {
    if (($msgtags(msg-param-months).key) >= 3) {
      msg $1 !bonus $msgtags(display-name).key $calc( 500 + 100 * ( $msgtags(msg-param-months).key % 3 ) )
    }
  }
}

Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
@FoxInABox

Hey, thank you for your reply! Just to make sure that I don't need more than this part, or do I need to add more lines in there? I mean does it calculate auto for 6 months, 9 months, etc?

Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key == 12665) && (resub isin $msgtags) {
    if (($msgtags(msg-param-months).key) >= 3) {
      msg $1 !bonus $msgtags(display-name).key $calc( 500 + 100 * ( $msgtags(msg-param-months).key % 3 ) )
    }
  }
}



Alright, I had this running and happened this:

Last edited by Furiny; 14/11/16 01:49 PM.
Joined: Oct 2016
Posts: 14
F
Pikka bird
Offline
Pikka bird
F
Joined: Oct 2016
Posts: 14
Sorry, the % actually returns the reminder (I use to get them mixed up in another programming language), instead we have to check how many times it can be divided with 3 and then floor that value before multiplying it with the 100.

It should calculate a bonus 100 gold for every 3rd month with this:
Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key == 12665) && (resub isin $msgtags) {
    if (($msgtags(msg-param-months).key) >= 3) {
      msg $1 !bonus $msgtags(display-name).key $calc( 500 + 100 * ( $floor( $calc( $msgtags(msg-param-months).key / 3 ) - 1 ) ) )
    }
  }
}

EDIT: added a -1 since if it starts at 3, then 3/3 will will give a bonus 100 right away

Could also start it at 400 as an alternative:
$calc( 400 + 100 * ( $floor( $calc( $msgtags(msg-param-months).key / 3 ) ) ) )

Not sure if I need the extra $calc there

Last edited by FoxInABox; 14/11/16 04:18 PM.
Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
Thank you, edited the script. Have it running at moment, let's see. smile

Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
The script did give now 21month bonus - even though subscriber is at 7month.



Current code:
Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key == 12665) && (resub isin $msgtags) {
    if (($msgtags(msg-param-months).key) >= 3) {
      msg $1 !bonus $msgtags(display-name).key $calc( 500 + 100 * ( $floor( $calc( $msgtags(msg-param-months).key / 3 ) - 1 ) ) )
    }
  }
}

Last edited by Furiny; 14/11/16 04:34 PM.
Joined: Oct 2016
Posts: 14
F
Pikka bird
Offline
Pikka bird
F
Joined: Oct 2016
Posts: 14
I tested it this time, I messed up the brackets:
Code:
$calc( 500 + 100 *   $floor( $calc( ( X / 3 ) - 1 ) ) ) ;correct
$calc( 500 + 100 * ( $floor( $calc(   X / 3 ) - 1 ) ) ) ;wrong


Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key == 12665) && (resub isin $msgtags) {
    if (($msgtags(msg-param-months).key) >= 3) {
      msg $1 !bonus $msgtags(display-name).key $calc( 500 + 100 *   $floor( $calc( ( $msgtags(msg-param-months).key / 3 ) - 1 ) ) )
    }
  }
}

><;; hopefully there won't be any need for further edits

Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
So complicated! frown


Joined: Oct 2016
Posts: 14
F
Pikka bird
Offline
Pikka bird
F
Joined: Oct 2016
Posts: 14
I'm not sure why it triggers there, it shouldn't do so unless it is greater or equal to 3 .. err .. maybe remove the extra set of brackets around the key?
Code:
    if ( $msgtags(msg-param-months).key >= 3 ) {

..and replace line 3 with that?

But it is correct that it should give a 400 as a value if it goes through at 2.

Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
No currencies given to 2nd month resubscribers - so 3,6,9,12,15,18,21 etc.. I have first month script running fine.

Last edited by Furiny; 14/11/16 07:09 PM.
Joined: Oct 2016
Posts: 14
F
Pikka bird
Offline
Pikka bird
F
Joined: Oct 2016
Posts: 14
I was just saying that the value it shows was as expected if it would trigger at month 2.

But it is strange that >= 3 doesn't work, try replace that line with:
Code:
if ($msgtags(msg-param-months).key > 0 ) && (3 // $msgtags(msg-param-months).key) {

X > 0 -> makes sure that it have to be larger then 0
3 // x -> makes sure that it have to be 0 3 6 and so on

Last edited by FoxInABox; 14/11/16 07:52 PM.
Page 1 of 2 1 2

Link Copied to Clipboard