mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
(TWITCH) Adding currencies #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!

Re: (TWITCH) Adding currencies [Re: Furiny] #259257 24/10/16 12:37 AM
Joined: May 2015
Posts: 133
K
keyeslol Offline
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
Re: (TWITCH) Adding currencies [Re: keyeslol] #259259 24/10/16 01:03 PM
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?

Re: (TWITCH) Adding currencies [Re: Furiny] #259261 24/10/16 04:54 PM
Joined: May 2015
Posts: 133
K
keyeslol Offline
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
Re: (TWITCH) Adding currencies [Re: keyeslol] #259262 24/10/16 06:23 PM
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?

Re: (TWITCH) Adding currencies [Re: Furiny] #259263 24/10/16 07:07 PM
Joined: May 2015
Posts: 133
K
keyeslol Offline
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
Posts: 133
Yes.


twitter @keyeslol
Re: (TWITCH) Adding currencies [Re: keyeslol] #259264 24/10/16 07:21 PM
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
      } 
    }
  }

Re: (TWITCH) Adding currencies [Re: Furiny] #259265 24/10/16 07:33 PM
Joined: May 2015
Posts: 133
K
keyeslol Offline
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
Re: (TWITCH) Adding currencies [Re: keyeslol] #259266 24/10/16 08:30 PM
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


Re: (TWITCH) Adding currencies [Re: Furiny] #259379 14/11/16 12:02 AM
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
      } 
    }
  }

Re: (TWITCH) Adding currencies [Re: Furiny] #259383 14/11/16 06:26 AM
Joined: Oct 2016
Posts: 14
F
FoxInABox Offline
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 ) )
    }
  }
}

Re: (TWITCH) Adding currencies [Re: FoxInABox] #259385 14/11/16 12:45 PM
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.
Re: (TWITCH) Adding currencies [Re: Furiny] #259388 14/11/16 04:10 PM
Joined: Oct 2016
Posts: 14
F
FoxInABox Offline
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.
Re: (TWITCH) Adding currencies [Re: FoxInABox] #259389 14/11/16 04:22 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

Re: (TWITCH) Adding currencies [Re: FoxInABox] #259390 14/11/16 04:28 PM
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.
Re: (TWITCH) Adding currencies [Re: Furiny] #259391 14/11/16 06:05 PM
Joined: Oct 2016
Posts: 14
F
FoxInABox Offline
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

Re: (TWITCH) Adding currencies [Re: FoxInABox] #259392 14/11/16 06:21 PM
Joined: Sep 2016
Posts: 34
F
Furiny Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2016
Posts: 34
So complicated! frown


Re: (TWITCH) Adding currencies [Re: Furiny] #259393 14/11/16 06:49 PM
Joined: Oct 2016
Posts: 14
F
FoxInABox Offline
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.

Re: (TWITCH) Adding currencies [Re: FoxInABox] #259394 14/11/16 06:57 PM
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.
Re: (TWITCH) Adding currencies [Re: Furiny] #259395 14/11/16 07:51 PM
Joined: Oct 2016
Posts: 14
F
FoxInABox Offline
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