Author Topic: Code To Make SubTrain deactivate after 5 min of no new subs  (Read 2620 times)

0 Members and 1 Guest are viewing this topic.

ladman

  • Youngling
  • *
  • Posts: 38
  • Karma: +1/-0
    • View Profile
  • Twitch Name: legendaryladman
Hello,

Im looking for someone or some knowledge on how to make a subtrain counter on the stream go deactivate after 5 minutes of no new subs.

Currently, i it set up with a command that will activate a bar that has the counter and subtrain timer on screen, this will show up on stream when a sub occurs with obs remote. But what i now need is the logic to make it go away if there are no new subs after 5 minutes but keep it on screen when during it being activated and when a new sub happens, reset the timer.

pretty much

if ( subcount = +1 )
[ reset time();
else if
(subtimer == 300 and subcount = previous subcount )
do
!subtrainoff

or something like this

ladman

  • Youngling
  • *
  • Posts: 38
  • Karma: +1/-0
    • View Profile
  • Twitch Name: legendaryladman
Re: Code To Make SubTrain deactivate after 5 min of no new subs
« Reply #1 on: July 08, 2017, 01:30:12 PM »
Can anyone help with this?

ladman

  • Youngling
  • *
  • Posts: 38
  • Karma: +1/-0
    • View Profile
  • Twitch Name: legendaryladman
Re: Code To Make SubTrain deactivate after 5 min of no new subs
« Reply #2 on: July 13, 2017, 05:24:14 AM »
does no one out there know how have this done? there has to be a way of doing it.

Dante557

  • Advisor
  • Councilor
  • **
  • Posts: 555
  • Karma: +26/-0
  • Sometimes Helpful, Sometimes Not :D
    • View Profile
    • My Twitch Page
  • Twitch Name: Dante557
Re: Code To Make SubTrain deactivate after 5 min of no new subs
« Reply #3 on: July 16, 2017, 10:47:14 PM »
Thinking about this logically it is possible to do. However it would require a command running in the background to check the status every minute or so. Depending how many subs you pull in the following could get quite messy but you'd need to do the following

1) We need a text file to save the current time in seconds. We can use @unixtime@ for this particular purpose.
- Create a new folder in Custom Logs called "subs"
- Create two text files in here. "subtrainnumber.txt" and "subtraintimer.txt"
- in "subtrainnumber.txt" save the text file with the number 0 in it.
2) Best case scenario would be to just enable and disable the looping command whenever it is run. We can use @enablecmd@ and @disablecmd@ to that effect.
3) The first command will do whatever you want it to do. You could make it more personalised like "Choo Choo! The train now has x subs on it. Full steam ahead!" for example.
4) Magic will happen in the command we'll create. It'll be a self executing one which will loop every minute. In theory this means it will loop 5 times and complete its journey.

With this example, the command names are !subtrain and !subtrain_2. You sub notification would call the !subtrain command when a new sub comes in

With that out the way this is how it should look

Code: [Select]
!subtrain

@if@[>||@calc@[+|@readfile@[subs/subtrainnumber.txt]|1]||1||Choo Choo, This train is going full steam ahead! @user@ has now subscribed to the stream||@user@ has just subscribed to the stream. The sub train has now left the station! Choo Choo!] @savefile@[subs/subtraintimer.txt,@calc@[+|@unixtime@|300]] @enablecmd@[!subtrain_2] @savefile@[subs/subtrainnumber.txt,@calc@[+|@readfile@[subs/subtrainnumber.txt]|1]] @exec@[60,!subtrain_2]

Code: [Select]
!subtrain_2

@if@[<=||@unixtime@||@readfile@[subs/subtraintimer.txt]||@exec@[60,!subtrain_2]||@disablecmd@[!subtrain_2] The sub train has ended with @readfile@[subs/subtrainnumber.txt] member(s) on board @savefile@[subs/subtrainnumber.txt,0]]
If you need to get through to me you can try to contact me on Twitter @ http://www.twitter.com/dante556

ladman

  • Youngling
  • *
  • Posts: 38
  • Karma: +1/-0
    • View Profile
  • Twitch Name: legendaryladman
Re: Code To Make SubTrain deactivate after 5 min of no new subs
« Reply #4 on: July 17, 2017, 11:06:45 PM »
Awesome!!!

Life saver man!