Apps Home
|
Create an App
Emma's Tip Counter
Author:
adinner
Description
Source Code
Launch App
Current Users
Created by:
Adinner
// vars var total_tipped = 0; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; cb.settings_choices = [{ name: 'raffle_chance', type: 'int', minValue: 0, maxValue: 100, label: 'What is the % chance for a user to win a raffle ticket on any tip? (Setting this to 0 will turn this off)', defaultValue: 1 },{ name: 'raffle_win_msg', type: 'str', label: 'What is the message to display to the user if they win a raffle ticket?', defaultValue: '[username] has won a raffle ticket!!' }]; // handlers cb.onTip(function(tip) { if(cb.settings.raffle_chance > 0) { var randomChance = (Math.ceil(Math.random()*100)); cb.log('Random ticket chance: '+randomChance+' '+cb.settings.raffle_chance); if(randomChance <= cb.settings.raffle_chance) { cb.sendNotice(cb.settings.raffle_win_msg.replace('[username]',tip['from_user'])); } } total_tipped += tip['amount'] last_tip_amount = tip['amount'] last_tip_username = tip['from_user'] if (tip['amount'] > high_tip_amount) { high_tip_amount = tip['amount'] high_tip_username = tip['from_user'] } cb.drawPanel(); }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tips Received :', 'row1_value': '' + total_tipped, 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; }); function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } }
© Copyright Chaturbate 2011- 2025. All Rights Reserved.