Apps Home
|
Create an App
joes crazy ticket
Author:
hardworkertntest
Description
Source Code
Launch App
Current Users
Created by:
Hardworkertntest
// Title: Joes Crazy Ticket // Author: hardworkertn // Version: 1.0 (11/12/2021) cb.settings_choices = [ {name: 'min_start_tokens', type: 'int', minValue: 1, maxValue: 1000, defaultValue: 49, label: "Ticket Show Price"}, {name: 'hide_message', label: 'Cam Message', type: 'str', minLength: 1, maxLength: 256, defaultValue: 'Joes Crazy Ticket Show! Tip at least ' + cb.settings.min_start_tokens + ' tokens to join in on the fun!' }, {name: 'color', label: 'Color', type: 'str', defaultValue: '#DC0000', required: false}, {name: 'commanders', label: 'Allow these users to operate the timer', type: 'str', defaultValue: 'hardworkertn', required: false}, {name: 'allow_mods', label: 'Allow all moderators to operate the timer', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, {name: 'timer_cmd', label: 'Timer command', type: 'str', defaultValue: '/timer', required: false}, ]; // ****************************************** // GLOBAL VARIABLES // ****************************************** var userlist = ["hardworkertn"]; x_totaltickets=0; var total_tickets = 0; random=Math.random()*100; var timerMinutes = 0; var timerdesc=''; var timermessage='' //timer variables var $ = JSON.parse(JSON.stringify(cb.settings)); var say = (message, user, color, wt) => cb.sendNotice(newLines(message), user, '', color || $.color || '#DC0000', wt || $.weight || 'bold'); var newLines = (input) => '|\u2007 ' + input.replace(/\n/g, '\n|\u2007 '); var isAllowed = (msg) => commanders.includes(msg.user) || (msg.is_mod && cb.settings.allow_mods === 'Yes'); var commanders = $.commanders ? $.commanders.split(/\s*,\s*/).filter((obj) => obj.length) : []; commanders.push(cb.room_slug); //main code cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tickets Sold:', 'row1_value': '' + total_tickets, 'row2_label': 'Tickets Price:', 'row2_value': '' + cb.settings.min_start_tokens, 'row3_label': timerdesc, 'row3_value': '' + timermessage }; }); cb.onStart(user => { //msg['background'] = '#9F9'; cb.chatNotice( '------------------------------------------------------------'); cb.chatNotice( ':hardworkerlogo'); cb.chatNotice(' JOES CRAZY TICKET APP!'); cb.chatNotice( '------------------------------------------------------------'); //msg['background'] = ''; }); cb.onTip(function(tip) { if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), tip['from_user'])) { if(parseInt(tip['amount']) >= cb.settings.min_start_tokens) { //output('Added '+ tip['from_user'] + ' to secret show!'); output_user(tip['from_user'], 'You have been added to the crazy ticket list!'); total_tickets = userlist.length; cb.drawPanel(); //showCam(tip.from_user); if (cb.limitCam_isRunning()){ //output("app is running for loop"); cb.limitCam_addUsers(tip.from_user); } //handleTip(tip.amount, tip.from_user); checkTicket(tip.from_user); if (checkflag == false){ handleArray(tip.from_user); } //output('Current Users: ' + userlist); } if(parseInt(tip['amount']) < cb.settings.min_start_tokens) { //output_user(tip['from_user'], 'You must tip ' + cb.settings.min_start_tokens + ' or more to watch the show!'); lotteryTicket(tip.from_user,tip.amount); } } }); // functions function handleTip(amount,user){ } function lotteryTicket(username,amount){ //output('random:'+random); //output('user: '+username); //output('amount: '+amount); var newrandom=getRandomInt(1,cb.settings.min_start_tokens); //output('new random: ' + newrandom); checkTicket(username); //output(checkflag); if (amount == newrandom) { if (checkflag == false){ userlist.push(username); output_user(username,"***** LOTTERY WINNER *****"); output_user(username,"With your generous tip you partcipdated in the ticket lottery."); output_user(username,"Congratulations - You won a free ticket! Free tickets are a one time deal. Please do not beg the room or mods for free tickets."); output_user(username, 'You have been added to the crazy ticket list!'); output(":WINNER Congratulations to " + username + " for winning a free ticket in the Ticket Lottery! Tip less than " + cb.settings.min_start_tokens + " tokens to play"); processUser(username); } } else{ if (checkflag == false){ output_user(username,"With your generous tip you partcipated in the ticket lottery. Sorry, you did not win a free ticket. Please try again."); } } } function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } function handleArray(user){ // output('adding user: ' + user); userlist.push(user); // output('Current Users: ' + userlist); } function arrayRemove(value) { // output('incominguser list:' + userlist); return userlist.filter(function(ele){ return ele != value; }); // output('returned user list: ' + userlist); } function checkTicket(username){ checkflag = userlist.includes(username); //output(username + 'has a check flag: ' + checkflag); return checkflag; } function checkMessage(username,message){ if (message.includes("refund")==true){ output_user(username,"Refunds are not allowed. Tips are not a gaurantee of sexual activity."); } if (message.includes("fag")==true){ output_user(username,"Fag is generally a derogatory term in the united states."); } if (message.includes("replay")==true){ output_user(username,"Please read the room rules. Rules are to keep the chat positive and horny."); } if (message.includes("rerun")==true){ output_user(username,"Please read the room rules. Rules are to keep the chat positive and horny."); } if (message.includes("snap")==true){ output_user(username,"Please do not share your snap in my chat. I will ban you."); } if (message.includes("snap")==true){ output_user(username,"Please do not advertise in my chat."); } } function addtoList(user){ var username = user['user']; checkTicket(username); //make sure we add them to the list. if (checkflag == false){ userlist.push(username); //output(userlist); } processUser(user) } function processUser(user){ var username = user['user']; var isFan = user['in_fanclub']; var is_Mod = user['is_mod']; checkflag = checkTicket(username); //check mod status and fan club again //mods and fan club are always added if (checkflag == false && isFan == true){ userlist.push(username); checkflag=true; } //check mod status and fan club again if (checkflag == false && is_Mod == true){ userlist.push(username); checkflag=true; } //if cam is running lets add them if (checkflag == true && cb.limitCam_isRunning()){ cb.limitCam_addUsers(username); //userlist.push(username); //output(userlist); } } function UserEnter(username,isFan,is_Mod){ if (is_Mod == true){ output(":ModPower Moderator " + username + " has entered the room"); } //funny alerts if (username == 'hornydaddybear6987'){ output_mod('hornydaddybear6987 is here ignore his stupidy.'); } } cb.onEnter(function(user) { // cb.chatNotice('Welcome ' + user['user'] + '!'); var username = user['user']; var isFan = user['in_fanclub']; var is_Mod = user['is_mod']; UserEnter(username,isFan,is_Mod); processUser(user); }); cb.onMessage(function (msg) { var message = msg['m']; var user = msg['user']; var username = msg['user']; // vars for ease of use var u = msg['user']; var m = msg['m']; var isMod = msg['is_mod']; var isFan = msg['in_fanclub']; var isModel = (u == cb.room_slug); var hasTokens = msg['has_tokens']; var hasTipped = msg['tipped_recently']; var isGrey = !(hasTokens || isMod || isModel || isFan); var modsAllowed = true; var exempt = (isModel || isMod); //timer if (isAllowed(msg)) ezTimer(msg); //are they valid to change things? admin=false; if (cb.room_slug == user){ admin=true; } if (isMod == true){ admin=true; } //output('admin status: ' + admin); checkMessage(username,message) if (message == '/reprocess'){ processUser(username); output_user(username," Your crazy ticket has been reprocessed"); } if (admin == true && message == '/start') { output(cb.room_slug + ' has started the show!'); //var userlist = cb.limitCam_allUsersWithAccess() cb.limitCam_start("Crazy Ticket Show: Tip " + cb.settings.min_start_tokens + " tokens. Wait a few seconds to automatically connect. If purchased refresh/re-enter room."); // now add the users from the array to the show. //now lets add people who are on the list //output('List Current Users: ' + userlist); let arraylength = userlist.length; output("Total ticket holders in the show: " +arraylength); cb.limitCam_removeAllUsers(); for (let i = 0; i < arraylength; i++) { username=userlist[i] cb.limitCam_addUsers([username]); //output("added from array: " + username); } output("All paid ticket holders have been added. You may need to refresh your browser."); timerdesc=''; timermessage=''; cb.drawPanel(); } // if (cb.room_slug === user && message == '/stop' && cb.limitCam_isRunning()) { if (admin == true && message == '/stop') { output(cb.room_slug + ' has stopped the show!'); cb.limitCam_stop(); cb.limitCam_removeAllUsers(); new_subject="Crazy Ticket show has ended. Cam is now in public view."; cb.changeRoomSubject(new_subject); timerdesc=''; timermessage=''; cb.drawPanel(); } if (admin == true && message.substring(0, 6) == '/check') { username = message.substring(7, message.length); checkflag = userlist.includes(username); output(username + 'has a ticket: ' + checkflag); // if (cb.limitCam_userHasAccess(username)) { // output_mod(username + " is in the show!"); // } // else { // output_mod(username + " is not in the show!"); // } } //if (cb.room_slug === user && message.substring(0, 7) == '/remove' && cb.limitCam_allUsersWithAccess().length > 0) { if (admin == true && message.substring(0, 7) == '/remove') { username = message.substring(8, message.length); output_mod(username + ' has removed from the show!'); userlist = arrayRemove(username); // output('var userlist result: ' + userlist); if (cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), username)) { cb.limitCam_removeUsers([username]); } } if (admin == true && message.substring(0, 4) == '/add') { // output('message: ' + message); username = message.substring(5, message.length); //output('username: ' + username); //handleArray(username); //output('adding user: ' + username); checkTicket(username); if (checkflag == false){ userlist.push(username); } //output('Current Users: ' + userlist); if (cb.limitCam_isRunning()){ //output("app is running for loop"); cb.limitCam_addUsers(username); } output_mod(username+' has been added to the crazy ticket show!'); output_user(username, ' you have been added to the crazy ticket show.'); total_tickets=total_tickets+1; cb.drawPanel(); } if (admin == true && message.substring(0, 7) == '/addmax') { addMax(); output_mod(cb.room_slug + '-- the max users were added'); } if (cb.room_slug === user && message === '/camlist') { var usercamlist = cb.limitCam_allUsersWithAccess(); if (usercamlist.length > 0) { output_mod("" + usercamlist.length + (usercamlist.length > 1 ? " users" : " user") + " in show: " + cbjs.arrayJoin(usercamlist, ", ")); } else { output_mod("No users in show."); } } if (admin == true && message === '/list') { let totaltickets = userlist.length; output_mod('Total in List: ' + totaltickets); //output_mod('List Current Users: ' + userlist); let arraylength = userlist.length; showlist=''; for (let i = 0; i < arraylength; i++) { username=userlist[i] showlist=showlist+username+", "; //output("added from array: " + username); } output_mod("List Current Users: " + showlist); } if (admin == true && message == '/reload' && cb.limitCam_isRunning()) { let arraylength = userlist.length; for (let i = 0; i < arraylength; i++) { username=userlist[i] cb.limitCam_addUsers([username]); //output("added from array: " + username); } output_mod("The users on the list have been reprocessed."); } if (admin == true && message == '/recalc') { let arraylength = userlist.length; total_tickets=arraylength cb.drawPanel(); } if (admin == true && message.substring(0, 8) == '/subject') { new_subject = message.substring(9, message.length); cb.changeRoomSubject(new_subject); output('Room subject changed to: ' + new_subject); } if (admin == true && message.substring(0, 7) == '/notice') { new_message = message.substring(8, message.length); output_room(new_message); } if (admin == true && message.substring(0, 4) == '/mod') { new_message = message.substring(5, message.length); output_mod(new_message); } if (message[0] == '/') { msg['X-Spam'] = true; } //if they bought a ticket, lets give them an icon checkTicket(username); var prefix=''; if (checkflag == true){ prefix=' :crazyticketshow '; } if (isFan == true){ prefix=' :fanclubsquare '; } if (isMod == true){ prefix=' :icon_mod '; } if (cb.room_slug == username){ prefix=' :star_olivia_dellvine '; } msg.m = prefix + msg.m; return msg; }); function output(message) { cb.chatNotice(message); } function output_room(message){ to_user=''; background='#0000FF'; foreground='#FFFFFF'; weight='bolder'; to_group=''; cb.sendNotice(message, to_user, background, foreground, weight, to_group) } function output_mod(message){ to_user=''; background='#ff0000'; foreground='#000000'; weight='bolder'; to_group='red'; cb.sendNotice(message, to_user, background, foreground, weight, to_group) to_user='hardworkertntest'; background='#ff0000'; foreground='#FFFFFF'; weight='bolder'; to_group=''; cb.sendNotice(message, to_user, background, foreground, weight, to_group) to_user='hardworkertn'; background='#ff0000'; foreground='#FFFFFF'; weight='bolder'; to_group=''; cb.sendNotice(message, to_user, background, foreground, weight, to_group) } function output_user(username,message){ to_user=username; background='#FFFF00'; foreground='#000000'; weight='bolder'; to_group=''; cb.sendNotice(message, to_user, background, foreground, weight, to_group) } function addMax(){ userlist.push('jackhard20'); userlist.push('pokeme777'); userlist.push('texancigar'); userlist.push('dontbeshy63'); userlist.push('hotinatlanta1'); userlist.push('manlover1960'); userlist.push('mr_bo_dangles'); userlist.push('markmajors'); userlist.push('beeatrical'); userlist.push('benle20024'); userlist.push('kyredneckjb'); userlist.push('hungdieselredneck'); userlist.push('ta79dcfm'); } function ezTimer (msg) { msg.m = msg.m.trim(); var index = msg.m.includes(' ') ? msg.m.indexOf(' ') : Infinity; var cmd = msg.m.slice(0, index); var prm = msg.m.slice(index + 1); if (cb.settings.timer_cmd === cmd) { msg['X-Spam'] = true; cb.log('Command detected...'); zTimer.operations(prm, msg.user); } } function evaluate(str, user) { try { var result = eval(str); var notice = 'TYPE: ' + typeof result + '\nVALUE: '; result === void 0 ? notice += 'undefined' : notice += JSON.stringify(result, null, '\u2007\u2007\u2007\u2007'); cb.setTimeout(() => {cb.sendNotice(newLines(notice), user, '', '#00CC00', '', '')}, 100); } catch (e) { cb.setTimeout(() => {cb.sendNotice(newLines(e.name + ': ' + e.message), user, '', '#FF0000', '', '')}, 100); } } var zTimer = {seconds: Infinity, timeLeft: Infinity}; zTimer.operations = function (args, user) { var p = args.split(/\s+/); if (!p[0]) { zTimer.help(user); return; } var op = p[0].toLowerCase(); switch (op) { case 'add': zTimer.add(true, p.slice(1)); break; case 'sub': zTimer.add(false, p.slice(1)); break; case 'stop': case 'cancel': zTimer.cancel(); break; case 'text': zTimer.setGoal(p.slice(1)); break; case 'help': zTimer.help(user); break; default: zTimer.start(p); break; } }; zTimer.goal = ''; zTimer.prep = 'in'; zTimer.cap = (text) => text.charAt(0).toUpperCase() + text.slice(1); zTimer.setGoal = (input) => {if (input && input.trim() && isFinite(zTimer.timeLeft)) zTimer.goal = input.trim()}; zTimer.say = (txt) => say(':star_olivia_dellvine ' + txt.replace(/\n/g, ' :star_olivia_dellvine\n :star_olivia_dellvine ') + ' :star_olivia_dellvine'); zTimer.help = function (user) { var sep = '\n' + '\u2007'.repeat(4); var output = [ '------------------------------------', '* EZ Timer --- Command List *', '------------------------------------', $.timer_cmd + ' [n]' + sep + 'Start [n]-minute timer', $.timer_cmd + ' for [n] [activity]' + sep + 'Start [n]-minute timer for continuous activity', $.timer_cmd + ' at [n] [activity]' + sep + 'Start [n]-minute timer with activity when timer reaches 0', $.timer_cmd + ' text [activity]' + sep + 'Update the current activity or action', $.timer_cmd + ' stop' + sep + 'Cancel the timer', $.timer_cmd + ' help' + sep + 'Show this menu again', ].join('\n'); say(output, user); }; zTimer.add = function (positive, p) { if (isFinite(zTimer.timeLeft)) { cb.log(positive ? 'Adding to timer...' : 'Subtracting from timer...'); var n = Number(p[0]); if (n) { cb.log('Adding ' + n); var phrase; if (positive) { phrase = 'added to'; } else { phrase = 'removed from'; n = n * -1; } zTimer.timeLeft += Math.round(n * 300); zTimer.say(n + ' minutes ' + phrase + ' the timer.'); } } }; zTimer.start = function (p) { cb.log('Starting timer...'); if (isNaN(Number(p[0]))) { p[0] = String(p[0]).toLowerCase().replace('at','in'); if (!['for','in','at'].includes(p[0])) return; zTimer.prep = p[0]; p.splice(0, 1); } else { zTimer.prep = 'in'; } var min = p[0]; var goal = p.slice(1).join(' '); if (min) { zTimer.timeLeft = Math.round(min * 60); zTimer.seconds = Math.round(min * 60); zTimer.goal = goal || ''; if (zTimer.goal) { if (zTimer.prep === 'in') goal = '\n' + zTimer.cap(goal) + ' at time up!'; if (zTimer.prep === 'for') goal = '\n' + zTimer.cap(goal) + ' until time up!'; } say(':starx\n' + min + ' minute timer set!' + goal + '\n:starx'); timerdesc='Showtime:'; timermessage=min + ' minute(s)'; cb.drawPanel(); } }; zTimer.cancel = function () { cb.log('Canceling timer...'); if (isFinite(zTimer.timeLeft)) { zTimer.timeLeft = Infinity; zTimer.seconds = Infinity; zTimer.goal = ''; zTimer.say('Timer cancelled!'); } }; zTimer.go = function () { if (zTimer.timeLeft > 0) { if (zTimer.timeLeft % 10 === 0) cb.log(zTimer.timeLeft + ' seconds left...'); if (zTimer.timeLeft % 60 === 0 && zTimer.timeLeft !== zTimer.seconds) { var mins = zTimer.timeLeft / 60; var mins_word = ' minute' + (mins === 1 ? '' : 's'); if (zTimer.goal) { zTimer.say(zTimer.cap(zTimer.goal) + ' ' + zTimer.prep + ' ' + mins + (zTimer.prep === 'for' ? ' more ' : '') + mins_word + '!'); } else { zTimer.say('--------------------------------------\n' + mins + mins_word + ' left to buy a crazy ticket!\nTip '+cb.settings.min_start_tokens+' tokens to see the show.\n--------------------------------------'); timerdesc='Showtime:'; timermessage=mins + mins_word; cb.drawPanel(); } } zTimer.timeLeft--; } else { // zTimer.say(':timesup\n:timesup\n:timesup'); timerdesc=''; timermessage=''; cb.drawPanel(); zTimer.timeLeft = Infinity; zTimer.seconds = Infinity; zTimer.goal = ''; } cb.setTimeout(zTimer.go, 1000); }; zTimer.go(); zTimer.help(cb.room_slug);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.