Apps Home
|
Create an App
just4gabby
Author:
theharrinator
Description
Source Code
Launch App
Current Users
Created by:
Theharrinator
var times_goal_reached = 0; var last_time_goal_reached = null; var current_goal_tipped = 0; var current_description = null; var current_free_tips = 0; var timeint_just4u_notice = 0; var timeint_wheel_notice = 0; var just4u_color = '#F9DBFE'; var wheel_color = '#CEFAD6'; var set_tokens_command = '!settok'; var set_reached_command = '!setreached'; var new_subject_command = '!status'; var help_command = '!help'; var just4u_command = '!j4etimer'; var autoreset_command = '!autoreset'; var wheel_command = '!wheel'; var wheel_reward_command = '!reward'; var tipnote_text = 'xmasbox'; var app_title = 'Gabby\'s Santa Gift'; var notice_text = 'Type ' + tipnote_text + ' at the beginning of your tip note, if your tip should not count for the goal, and should count for ' + app_title + '.'; var notice_text = notice_text + ' :xmashearts'; cb.settings_choices = [{ name: 'goal_description', type: 'str', defaultValue: '', minLength: 1, maxLength: 255, label: 'Room\'s status' }, { name: 'just4u_activation', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Do you want to activate the just4u function?' }, { name: 'Just4V_notice_timer', type: 'int', minValue: 0, default: 60, label: 'Time interval to display the "just4u" notice in seconds (0 = never)' }, { name: 'autoreset_activation', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Do you want to activate the Auto-Reset Tip Goal?' }, { name: 'tokens', type: 'int', minValue: 1, default: 100, label: 'Tokens to reach the Auto-Reset Tip Goal' }, { name: 'received_tokens', type: 'int', minValue: 0, default: 0, label: 'Already received tokens' }]; function refresh() { cb.log("Refresh called"); cb.setTimeout(refresh, 20000); cb.drawPanel() } function update_subject() { var a = current_description; if (cb.settings.autoreset_activation == 'Yes') { a += " [" + tips_remaining() + " tokens remaining]" } cb.log("Changing subject to: " + a); cb.changeRoomSubject(a) } function goalReached(a) { last_time_goal_reached = new Date(); var b = Math.floor(current_goal_tipped / cb.settings.tokens); for (var i = 0; i < b; i++) { times_goal_reached++; current_goal_tipped -= cb.settings.tokens; if (a != '') { cb.sendNotice("Goal was reached for the " + getNumberString(times_goal_reached) + " time!"); cb.sendNotice('The user ' + a + ' has reached the goal.', cb.room_slug, "#FEF9CD", "#1A1AD7", "") } } } function getNumberString(a) { var b = null; var c = String(a).charAt(String(a).length - 1); if ((c == '1') && (a != 11)) { b = a + "st" } else if ((c == '2') && (a != 12)) { b = a + "nd" } else if ((c == '3') && (a != 13)) { b = a + "rd" } else { b = "" + a + "th" } return (b) } function tips_remaining() { var r = cb.settings.tokens - current_goal_tipped; if (r < 0) { return 0 } else { return r } } function notice_just4u() { if ((cb.settings.just4u_activation == 'Yes') && (timeint_just4u_notice > 0)) { cb.sendNotice(notice_text, '', just4u_color, '#000000', ''); cb.setTimeout(notice_just4u, parseInt(timeint_just4u_notice)) } } function notice_wheel() { if ((cb.settings.wheel_activation == 'Yes') && (timeint_wheel_notice > 0)) { cb.sendNotice(cb.room_slug + '\'s Wheel of Fortune [for V].\nTip ' + cb.settings.wheel_tokens + ' to spin the Wheel of Fortune. Type !reward to display the rewards.', '', wheel_color, '#000000', ''); cb.setTimeout(notice_wheel, parseInt(timeint_wheel_notice)) } } function startsWith(a, b) { return a.substring(0, b.length).toUpperCase() === b.toUpperCase() } function spinWheel(a) { var b = ''; if (cb.settings.wheel_activation == 'Yes') { var c = Math.floor(Math.random() * (rewards.length)); b += '==================================================\n'; b += 'Spinning the Wheel of Fortune for ' + a + '\n'; b += 'Wheel stopped on: ' + rewards[c] + '\n'; b += '==================================================\n'; cb.sendNotice(b, '', wheel_color, '#000000', '') } } var temp_rewards = new Array(cb.settings.pos1, cb.settings.pos2, cb.settings.pos3, cb.settings.pos4, cb.settings.pos5, cb.settings.pos6, cb.settings.pos7, cb.settings.pos8, cb.settings.pos9, cb.settings.pos10, cb.settings.pos11, cb.settings.pos12, cb.settings.pos13, cb.settings.pos14, cb.settings.pos15, cb.settings.pos16, cb.settings.pos17, cb.settings.pos18, cb.settings.pos19, cb.settings.pos20, cb.settings.pos21, cb.settings.pos22, cb.settings.pos23, cb.settings.pos24, cb.settings.pos25, cb.settings.pos26, cb.settings.pos27, cb.settings.pos28, cb.settings.pos29, cb.settings.pos30); var rewards = new Array(); for (var i = 0; i < temp_rewards.length; i++) { if (temp_rewards[i] != '') { rewards.push(temp_rewards[i]) } } if (cb.settings.just4u_activation == 'Yes') { timeint_just4u_notice = cb.settings.Just4V_notice_timer * 1000; if (timeint_just4u_notice > 0) { cb.setTimeout(notice_just4u, parseInt(timeint_just4u_notice)) } } if (cb.settings.wheel_activation == 'Yes') { timeint_wheel_notice = cb.settings.wheel_notice_timer * 1000; if (timeint_wheel_notice > 0) { cb.setTimeout(notice_wheel, parseInt(timeint_wheel_notice)) } } function init() { if (cb.settings.just4u_activation == 'Yes') { cb.sendNotice(notice_text, '', just4u_color, '#000000', '') } cb.settings.wheel_activation == 'No'; current_description = cb.settings.goal_description; current_goal_tipped = cb.settings.received_tokens; if (current_goal_tipped >= cb.settings.tokens) { goalReached('') } cb.drawPanel(); update_subject() } cb.onTip(function(a) { if ((cb.settings.just4u_activation == 'Yes') && (startsWith(a['message'], tipnote_text))) { current_free_tips += a['amount']; if ((cb.settings.autoreset_activation == 'Yes') && (cb.settings.wheel_activation == 'Yes')) { cb.sendNotice('Thanks to ' + a['from_user'] + '. This tip doesn\'t count for the Auto-Reset Goal and ' + a['from_user'] + ' doesn\'t want to spin the Wheel of Fortune.', '', just4u_color, '#000000', '') } else if (cb.settings.autoreset_activation == 'Yes') { cb.sendNotice('Thanks to ' + a['from_user'] + '. This tip doesn\'t count for the Auto-Reset Goal.', '', just4u_color, '#000000', '') } else if (cb.settings.wheel_activation == 'Yes') { cb.sendNotice('Thanks to ' + a['from_user'] + '. ' + a['from_user'] + ' doesn\'t want to spin the Wheel of Fortune.', '', just4u_color, '#000000', '') } } else { if ((cb.settings.wheel_activation == 'Yes') && (a['amount'] == cb.settings.wheel_tokens)) { spinWheel(a['from_user']) } current_goal_tipped += a['amount']; if (current_goal_tipped >= cb.settings.tokens) { goalReached(a['from_user']) } } update_subject(); cb.drawPanel() }); cb.onMessage(function(a) { var b = ''; if (a['m'][0] == '!') { if (a['user'] == cb.room_slug) { if (startsWith(a['m'], set_tokens_command)) { a['X-Spam'] = true; var c = a['m'].slice(set_tokens_command.length); times_goal_reached = Math.floor(c / cb.settings.tokens); current_goal_tipped = cb.settings.tokens; last_time_goal_reached = new Date(); cb.drawPanel(); cb.sendNotice('The tokens received has been updated!', a['user']) } else if (startsWith(a['m'], set_reached_command)) { a['X-Spam'] = true; var c = a['m'].slice(set_reached_command.length); times_goal_reached = c; last_time_goal_reached = new Date(); current_goal_tipped = 0; cb.drawPanel(); cb.sendNotice('The number of times reached has been updated!', a['user']) } else if (startsWith(a['m'], new_subject_command)) { a['X-Spam'] = true; var d = a['m'].slice(new_subject_command.length + 1); current_description = d; update_subject(); cb.drawPanel() } else if (startsWith(a['m'], just4u_command)) { a['X-Spam'] = true; var e = timeint_just4u_notice; timeint_just4u_notice = parseInt(a['m'].slice(just4u_command.length + 1)) * 1000; if (e == 0) { notice_just4u() } } } else { if (cb.settings.just4u_activation == 'Yes') { if (startsWith(a['m'], help_command)) { a['X-Spam'] = true; cb.sendNotice(notice_text, '', just4u_color, '#000000', ''); cb.sendNotice('Command !j4etimer [Number of seconds]: allow you to define the time interval to display the "just4u" notice. Red and green can use it.', '', just4u_color, '', '', 'red'); cb.sendNotice('Command !j4etimer [Number of seconds]: allow you to define the time interval to display the "just4u" notice. Red and green can use it.', '', just4u_color, '', '', 'green') } else if (startsWith(a['m'], just4u_command)) { if ((a['is_mod'] == true) || (a['in_fanclub'] == true)) { a['X-Spam'] = true; var f = timeint_just4u_notice; timeint_just4u_notice = parseInt(a['m'].slice(just4u_command.length + 1)) * 1000; if (f == 0) { notice_just4u() } } } } } if (startsWith(a['m'], wheel_reward_command)) { a['X-Spam'] = true; if (cb.settings.wheel_activation == 'Yes') { cb.sendNotice(cb.room_slug + '\'s Wheel of Fortune [for V]. The rewards.', '', wheel_color, '#000000', 'bold'); for (var i = 0; i < rewards.length; i++) { b += (i + 1) + '. ' + rewards[i] + '\n' } cb.sendNotice(b, '', wheel_color, '#000000', '') } } } }); cb.onDrawPanel(function(a) { if (cb.settings.autoreset_activation == 'Yes') { if (cb.settings.just4u_activation == 'Yes') { if (times_goal_reached == 0) { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Tokens "' + tipnote_text + '":', 'row2_value': '' + current_free_tips, 'row3_label': 'Hit Goal / Last Time:', 'row3_value': '' + times_goal_reached + ' time / Never' } } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Tokens "' + tipnote_text + '":', 'row2_value': '' + current_free_tips, 'row3_label': 'Hit Goal / Last Time:', 'row3_value': '' + times_goal_reached + ' time(s) / ' + Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' min ago' } } } else { if (times_goal_reached == 0) { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': 'Never' } } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': '' + Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' minutes ago' } } } } else { if (cb.settings.just4u_activation == 'Yes') { return { 'template': '3_rows_of_labels', 'row1_label': '', 'row1_value': '', 'row2_label': 'Tokens 4 "' + tipnote_text + '":', 'row2_value': '' + current_free_tips, 'row3_label': '', 'row3_value': '' } } } }); init(); cb.setTimeout(refresh, 20000);
© Copyright Chaturbate 2011- 2025. All Rights Reserved.