Bots Home
|
Create an App
Tiffs password show
Author:
masseffect_
Description
Source Code
Launch Bot
Current Users
Created by:
Masseffect_
// Name: Box Office // Version: 0.1.1/2012.12.04 var boxoffice = { init: function () { boxoffice.show = cb.settings.show; boxoffice.ticket = cb.settings.ticket; boxoffice.price = (Math.floor(cb.settings.price) > 0) ? Math.floor(cb.settings.price) : 0; boxoffice.required = (Math.floor(cb.settings.required) > 0) ? Math.floor(cb.settings.required) : 0; boxoffice.stock = (Math.floor(cb.settings.stock) > 0) ? Math.floor(cb.settings.stock) : 0; boxoffice.close_in = (Math.floor(cb.settings.duration) > 0) ? Math.floor(cb.settings.duration) : 0; boxoffice.sold = 0; boxoffice.tokens = 0; boxoffice.strings = { billboard: null, row1: { label: null, value: null }, row2: { label: null, value: null }, row3: { label: null, value: null } }; boxoffice.patrons = {}; if (boxoffice.close_in > 0) { boxoffice.timed = true; boxoffice.clock = true; cb.setTimeout(boxoffice.tick, 10000); } boxoffice.update(true); }, purchase: function (name, amount, message) { boxoffice.tokens += amount; if (!boxoffice.patrons[name]) { boxoffice.patrons[name] = { name: name, admitted: false, tokens: 0 }; } boxoffice.patrons[name].tokens += amount; if (!boxoffice.patrons[name].admitted && amount >= boxoffice.price && message == 'Yes') { boxoffice.sold++; boxoffice.patrons[name].admitted = true; cb.chatNotice(name+' purchased a ticket for your '+boxoffice.show+' show.',cb.room_slug); cb.chatNotice('Thank you for purchasing a ticket for my '+boxoffice.show+' show! The password is '+boxoffice.ticket+' and it will begin when enough tickets are sold.',name); boxoffice.update(true); } }, update: function (update_billboard) { if (boxoffice.closed) { return; } boxoffice.strings.row1.label = 'Box Office:'; if ((boxoffice.timed && boxoffice.close_in <= 0) || (boxoffice.stock && boxoffice.stock <= boxoffice.sold)) { // Closed update_billboard = true; boxoffice.closed = true; if (boxoffice.required && boxoffice.sold < boxoffice.required) { boxoffice.cancelled = true; } boxoffice.strings.row1.value = (!boxoffice.cancelled) ? 'Closed - '+boxoffice.show+' show starting' : 'Closed - Show cancelled'; boxoffice.strings.row2.label = null; boxoffice.strings.row2.value = null; } else { // Open if (boxoffice.timed) { var end_unit = ''; var end = boxoffice.close_in; if (end >= 60) { end_unit = 'minute'; end = Math.floor(end/60); } else { end_unit = 'second'; } if (end > 1 || end == 0) { end_unit = end_unit+'s'; } end = end+' '+end_unit; } boxoffice.strings.row1.value = (boxoffice.timed) ? boxoffice.show+' ('+end+' left)' : boxoffice.show; boxoffice.strings.row2.value = ''+boxoffice.sold+((boxoffice.stock) ? '/'+boxoffice.stock : '')+' sold'+((boxoffice.required) ? ' ('+(boxoffice.required-boxoffice.sold)+' more needed)' : ''); } var v = 'Type /tickets to see a list of all tickets sold'; if (!boxoffice.strings.row2.value) { boxoffice.strings.row2.value = v; boxoffice.strings.row3.value = null; } else { boxoffice.strings.row3.value = v; } cb.drawPanel(); if (update_billboard) { boxoffice.billboard(); } }, billboard: function () { if (boxoffice.closed && !boxoffice.cancelled) { boxoffice.strings.billboard = 'The box office is now closed and you can\'t buy anymore tickets. The passworded '+boxoffice.show+' show will being shortly.'; } else if (boxoffice.closed && boxoffice.cancelled) { boxoffice.strings.billboard = 'The box office is now closed and you can\'t buy anymore tickets. Not enough tickets were sold so the show has been cancelled.'; } else { boxoffice.strings.billboard = 'Buy tickets for my passworded '+boxoffice.show+' show.'; if (boxoffice.stock) { boxoffice.strings.billboard = boxoffice.strings.billboard+' '+(boxoffice.stock-boxoffice.sold)+' tickets left.'; } if (boxoffice.required && boxoffice.required > boxoffice.sold) { boxoffice.strings.billboard = boxoffice.strings.billboard+' '+(boxoffice.required-boxoffice.sold)+' more tickets required for the show.'; } if (boxoffice.timed) { boxoffice.strings.billboard = boxoffice.strings.billboard+' The box office will close when the time runs out.'; } } cb.changeRoomSubject('Box Office: '+boxoffice.strings.billboard); }, send_tickets: function () { cb.chatNotice('== Boxoffice Tickets ==',cb.room_slug); var p; for (p in boxoffice.patrons) { if (boxoffice.patrons.hasOwnProperty(p) && boxoffice.patrons[p].admitted) { cb.chatNotice(boxoffice.patrons[p].name+' ('+boxoffice.patrons[p].tokens+' tokens total)',cb.room_slug); } } }, tick: function () { boxoffice.close_in -= 10; if (boxoffice.close_in <= 0) { boxoffice.close_in = 0; boxoffice.update(true); } else { boxoffice.clock = true; cb.setTimeout(boxoffice.tick, 10000); boxoffice.update(); } } } // Chaturbate API cb.settings_choices = [ { name: 'show', label: 'Show name', type: 'str', minLength: 1, maxLength: 255, default: 'Cum' }, { name: 'ticket', label: 'Show password', type: 'str', minLength: 1, maxLength: 255 }, { name: 'price', label: 'Ticket price', type: 'int', minValue: 1, default: 20 }, { name: 'required', label: 'Minimum tickets required for show to start', type: 'int', minValue: 1, default: 20 }, { name: 'stock', label: 'Amount of tickets available', type: 'int', minValue: 1, required: false }, { name: 'duration', label: 'Time limit for ticket sale (in seconds)', type: 'int', minValue: 1, required: false }, ]; cb.tipOptions(function(name) { var o = {} if (name != cb.room_slug && !boxoffice.closed) { o.options = [{label: 'Yes'}, {label: 'No'}]; o.label = 'Are you purchasing a ticket ('+boxoffice.price+' tokens)?'; } return o; }); cb.onDrawPanel(function (name) { return { 'template': '3_rows_12_21_31', 'row1_label': boxoffice.strings.row1.label, 'row1_value': boxoffice.strings.row1.value, 'row2_value': (boxoffice.strings.row2.value) ? boxoffice.strings.row2.value : null, 'row3_value': (name == cb.room_slug) ? boxoffice.strings.row3.value : null }; }); cb.onTip(function (tip) { boxoffice.purchase(tip['from_user'], parseInt(tip['amount']), tip['message']); }); cb.onMessage(function (msg) { if (msg['user'] != cb.room_slug && boxoffice.patrons[msg['user']] && boxoffice.patrons[msg['user']].admitted == true) { // Highlight ticket holders' messages msg['background'] = '#9F9'; } if (msg['user'] == cb.room_slug && msg['m'] == '/tickets') { // Send list of tickets sold msg['X-Spam'] = true; boxoffice.send_tickets(msg['user']); } return msg; }); boxoffice.init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.