Tina Show
Author: tina_key
Description Source Code Launch App Current Users

Short Description:

Tina Show

Full Description

/**
* App: Tina Ticket Show
* Version: 1.0
* Author: Tina
* Date: 7-13-2015
*/

cb.settings_choices = [
{
name: 'price',
type: 'int',
minValue: 1,
label: 'How much do you want to charge for your show?',
defaultValue: 25,
required: true
},
{
name: 'show_name',
type: 'str',
label: 'What type of show is this?',
defaultValue: 'Describe the Show Here',
required: true
},
{
name: 'free_show_for_mods',
type: 'choice',
label: 'Let your hardworking mods watch for free?',
choice1: 'Yes',
choice2: 'No',
defaultValue: 'Yes',
required: true
},
{
name: 'start_show_countdown',
type: 'choice',
label: 'When do you want to start the show? (in minutes)',
choice1: '5',
choice2: '10',
choice3: '15',
choice4: '20',
choice5: '25',
choice6: '30',
choice7: '35',
choice8: '40',
choice9: '45',
choice10: '50',
choice11: '55',
choice12: '60',
choice13: '90',
choice14: '120',
defaultValue: '30',
required: true
},
{
name: 'silence_grays',
type: 'choice',
label: 'Silence grays (people with no tokens)?',
choice1: 'Yes',
choice2: 'No',
required: true
}
];

// global vars
var timeLeft = 0;
var minsShowStarts = 0;
var showStarted = false;
var showEnded = false;
var showStartTime = new Date();
var showEndTime = new Date();
var tipCounter = 0;
var langTokens = (cb.settings.price > 1) ? 'tokens' : 'token';

cb.onTip(function (tip) {

if (parseInt(tip['amount']) >= cb.settings.price) {
if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), tip['from_user'])) {
cb.limitCam_addUsers([tip['from_user']]);
cb.sendNotice(tip['from_user'] + ' has bought a ticket to the show! What in the fuck are you waiting on you horny fucker?', '', '#ff9700', '#FFFFFF');
}
}

tipCounter += parseInt(tip['amount']);
cb.drawPanel();
});

cb.onDrawPanel(function (user) {
var guestList = cb.limitCam_allUsersWithAccess();
if (!showStarted && !showEnded) {
return {
'template': '3_rows_of_labels',
'row1_label': 'Ticket Price:',
'row1_value': cb.settings.price + ' ' + langTokens,
'row2_label': 'Ticket Holders:',
'row2_value': guestList.length + ' (' + tipCounter + ')',
'row3_label': 'Show Starts In:',
'row3_value': getTimeLeft()
};
} else if (showStarted && !showEnded) {

return {
'template': '3_rows_of_labels',
'row1_label': 'Ticket Price:',
'row1_value': cb.settings.price,
'row2_label': 'Thanks Bitches',
'row2_value': guestList.length + ' / ' + tipCounter,
'row3_label': 'Show Started At:',
'row3_value': showStartTime.toTimeString()
};
} else if (showEnded) {
var timeDelta = showEndTime - showStartTime;
var timeDeltaSecs = timeDelta / 1000;
var showLength = secondsToHms(timeDeltaSecs);

return {
'template': '3_rows_12_22_31',
'row1_label': 'Thank you!',
'row1_value': guestList.length + ' (' + tipCounter + ')',
'row2_label': 'Show Length:',
'row2_value': showLength,
'row3_value': 'Ticket Show Ended'
};
}
});

cb.onEnter(function (user) {
advertise(user['user']);
});

cb.onMessage(function (msg) {

if (cb.room_slug === msg['user'] && msg['m'].match(/\/startshow/i) && !cb.limitCam_isRunning()) {
msg['X-Spam'] = true;
startShow();
} else if (cb.room_slug === msg['user'] && msg['m'].match(/\/stopshow/i)) {
msg['X-Spam'] = true;
stopShow();
} else if (cb.room_slug === msg['user'] && msg['m'].match(/\/restartapp/i)) {
msg['X-Spam'] = true;
resetShow();
} else if (msg['m'].match(/\/guestlist/i)) {
msg['X-Spam'] = true;
showGuestList(msg['user'])
} else {

var guestList = cb.limitCam_allUsersWithAccess();
if (cbjs.arrayContains(guestList, msg['user']) || (msg['user'] == cb.room_slug)) {
if (cb.limitCam_isRunning()) {

cb.sendNotice(msg['user'] + ': ' + msg['m'], cb.room_slug, '', '', 'bold');

for (var i = 0; i < guestList.length; i++) {
if (msg['user'] != guestList[i]) {
cb.sendNotice(msg['user'] + ': ' + msg['m'], guestList[i], '', '', 'bold');
}
}

msg['X-Spam'] = true;

} else {
if (cb.room_slug != msg['user']) {
msg['m'] = ':tkt1 ' + msg['m'];
msg['background'] = '#DAFFFF';
}
}
} else {
if (cb.limitCam_isRunning() && (msg['user'] != cb.room_slug)) {

msg['X-Spam'] = true;
cb.sendNotice('Sorry! Only ticket holders may chat until the Ticket Show is over. You can still buy in though. :)', msg['user'], '', '#CC0000', 'bold');
}

if(!cbjs.arrayContains(guestList, msg['user']) && msg['is_mod'] && (cb.settings.free_show_for_mods == 'Yes')) {
cb.limitCam_addUsers([msg['user']]);
cb.sendNotice(msg['user'] + ' has been added to the show because they are fucking awesome!', '', '#00A300', '#FFFFFF');
}

if(!msg['has_tokens'] && (cb.settings.silence_grays == 'Yes')) {
msg['X-Spam'] = true;
cb.sendNotice('Sorry! Only people with tokens may chat while during the show. Feel free to buy some tokens.', msg['user'], '', '', 'bold');
}
}
}

return msg;
});

function advertise(username) {
var notices = "Oh, shit! Here we go! It's time to get your ticket for Tina show now! \n";

if (!showStarted) {
notices += "The show will start in " + getTimeLeft() + " \n";
}

if (!showEnded && !showStarted) {
cb.sendNotice(notices, username, '', '#FF0000', 'bold');


}
}

function secondsToHms(d) {
d = Number(d);
var h = Math.floor(d / 3600);
var m = Math.floor(d % 3600 / 60);
var s = Math.floor(d % 3600 % 60);
return ((h > 0 ? h + ' hrs ' : '') + (m > 0 ? (h > 0 && m < 10 ? '0' : '') + m + ' mins ' : ' ') + (s < 10 ? '0' : '') + s + ' secs');
}

function getTimeLeft() {
if (timeLeft > 0) return secondsToHms(timeLeft);
return 0;
}

function updateTimeLeft() {

if (timeLeft > 0 && !showEnded) {

if (timeLeft >= 5) {
timeLeft -= 5;
cb.setTimeout(updateTimeLeft, 5000);
}

cb.drawPanel();

if (timeLeft % 180 == 0) advertise();

if (timeLeft == 900) {
cb.sendNotice('Ticket Show starts in 15 minutes. THIS IS THE FINAL NOTICE TO GET YOUR FUCKING TICKET!', '', '#FF0000', '#FFFFFF', 'bold');
} else if (timeLeft % 180 == 0) {
cb.sendNotice('Ticket Show starts in ' + secondsToHms(timeLeft) + '.', '', '#FFFFAA', '#000000', 'bold');
}

} else {
if(!showStarted && !showEnded) {
var guestList = cb.limitCam_allUsersWithAccess();
if (guestList.length > 0) {
startShow();
} else {
resetShow();
}
}
}
}

function resetShow() {
cb.sendNotice('Ticket Show has been reset.', '', '#E0FFE0', '#000000', 'bold');

stopShow();
showStartTime = new Date();
showEnded = false;
tipCounter = 0;

init();
}

function startShow() {
showStarted = true;
showEnded = false;
timeLeft = 0;
showStartTime = new Date();
cb.drawPanel();

if (!cb.limitCam_isRunning()) {
cb.limitCam_start('Ticket Show is in progress. Tip ' + cb.settings.price + ' to join the show. Otherwise, chat with others and Tina will be back as soon as possible!');
}

var msg = 'Ticket Show Started!\n';
msg += 'Only ticket holders will be able to chat.';

cb.sendNotice(msg, '', '#0099FF', '#FFFFFF', 'bold')
}

function stopShow() {
if (showStarted) {
var msg = 'Ticket Show Ended!\n';
msg += 'Big thank you to all of the ticket holders!';
cb.sendNotice(msg, '', '#9933FF', '#FFFFFF', 'bold');
}

showStarted = false;
showEnded = true;
showEndTime = new Date();

var guestList = cb.limitCam_allUsersWithAccess();
if (guestList.length > 0) cb.limitCam_removeAllUsers();

if (cb.limitCam_isRunning()) cb.limitCam_stop();
cb.drawPanel();

cb.changeRoomSubject('Ticket Show Ended');
}

function showGuestList(username) {
var guestList = cb.limitCam_allUsersWithAccess();
var rowNum = 1;
var msg = '#### TICKET SHOW GUEST LIST ####';
for (var i = 0; i < guestList.length; i++) {
msg += "\n" + rowNum + ") " + guestList[i];
rowNum++;
}

cb.sendNotice(msg, username);
}

function init() {
cb.changeRoomSubject('Ticket Show: ' + cb.settings.show_name + ' (' + cb.settings.price + ' ' + langTokens + ')');
minsShowStarts = parseInt(cb.settings.start_show_countdown);
timeLeft = minsShowStarts * 60;
advertise();
cb.setTimeout(updateTimeLeft, 5000);
}

init();

© Copyright Freesexcam 2011- 2024. All Rights Reserved.