Apps Home
|
Create an App
sfd2342safsdf
Author:
raccoon_pig
Description
Source Code
Launch App
Current Users
Created by:
Raccoon_Pig
/* ******************************************************* * Title: KarenJackpot * Author: Ryan * ******************************************************* */ // vars var gTotalTipToday = 0; var gHighTipUsername = null; var gHighTipAmount = 0; var last_tip_username = null; var TIME_ONE_SEC = 1000; var TIME_ONE_MINUTE = 60 * TIME_ONE_SEC; var CONFIG_ADVERT_MINUTES = 1 * TIME_ONE_MINUTE; var EMOTE_STAR = ' :star_olivia_dellvine '; var EMOTE_STARS = EMOTE_STAR + EMOTE_STAR + EMOTE_STAR; var gLovenseTag = ' #lovense #lush #toy ' var gHashTag = ' #flash #pvt '; var gSetGoalCommand = '/setgoal'; var gSetGoalTextCommand = '/setgoaltext'; var gOptOutList = new Array(); var gUseSubject = true; var gUseLovense = true; var gCommandRaffleCanWin = '/togglewin'; var gCommandRaffleSetTicket = '/setticket'; var gCommandRaffleProcessWinner = '/startraffle'; var gCommandRaffleTicketHolder = '/showraffle'; var gCommandRaffleTicketCost = '/setticketcost'; var gCommandRaffleTicketCount = '/ticket'; var gSetTimerCommand = '/timer'; var gPause = false; var gTimer = -1; var gRaffleTicketCost = 99; var gRaffleEnable = true; // should be a string instead or return an enum var gRafflePrize = "Private show for 6tk/min (max 20 mins)"; var gRaffleTicketHolders = new Array(); var gSpecialUser = 'raccoon_pig'; // requires resetting too var playerStats = {}; var gameStats = {firstplace: '',secondplace: '',thirdplace: '',firsttips: 0,secondtips: 0,thirdtips: 0}; var gCurrentCommandArg = new Array(); // i'm abusing global variable here, this is used to store current command argument (only valid during command parsing) // you need to populate this, refer to init() for more information var gAdvertInformation = new Array(); var gCommandInformation = new Array(); var gGoalTarget = new Array(); /* SETTINGS */ cb.settings_choices = [ /**** SETTINGS ****/ { name: 'gameChoice', type: 'choice', choice1: 'Raffle', choice2: 'Multigoal', defaultValue: 'Raffle', label: 'Which game to use?' }, { name: 'lovense', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'Yes', label: 'Use lovense?' } ]; var gGoalDefaultValue = [ {text:"remove one clothing (20 mins)", cost:700}, {text:"remove one clothing (30 mins)", cost:1000}, {text:"remove one clothing ", cost:1000}, {text:"remove one clothing ", cost:1500}, {text:"will stay nude", cost:1000}, {text:"sexy dance", cost:1000}, {text:"close up on my body", cost:1500} ]; var gGoalMaxIndex = gGoalDefaultValue.length; var gCurrentGoalIndex = 0; var gGoalPool = 0; for (i = 0; i < gGoalMaxIndex; ++i) { goalIndex = i + 1; cb.settings_choices.push({ name: 'goalTextssss' + i, label: 'Goal #' + goalIndex, type: 'str', minLength: 1, maxLength: 255, required: true, defaultValue: gGoalDefaultValue[i].text }); cb.settings_choices.push({ name: 'goalRequirementssss' + i, label: 'Goal #' + goalIndex, type: 'int', defaultValue: gGoalDefaultValue[i].cost, minValue: 1, required: true }); } /* ON TIP */ cb.onTip(function (tip) { last_tip_username = tip['from_user']; gTotalTipToday += tip['amount']; if(tip['amount'] > gHighTipAmount) { gHighTipAmount = tip['amount']; gHighTipUsername = tip['from_user']; } if (last_tip_username in playerStats) { playerStats[last_tip_username].totaltips += tip['amount'] } else { playerStats[last_tip_username] = { totaltips: tip['amount'] } } // update tip statistic trackTips(last_tip_username, tip['amount']); if(inArray(last_tip_username, gOptOutList)) { notify(last_tip_username + ' opt out from prizes, tips will be ignored, type \'/opt\' to opt in/out from prizes'); } else { if(gRaffleEnable) { HandleRaffleTipping(tip['amount'], tip['from_user']); } else { if(gCurrentGoalIndex < gGoalMaxIndex) { gGoalPool += tip['amount']; if(gGoalPool >= gGoalTarget[gCurrentGoalIndex]) { notify(':goalreached3 ' + gGoalDefaultValue[gCurrentGoalIndex].text); notify(':goalreached3 ' + gGoalDefaultValue[gCurrentGoalIndex].text); notify(':goalreached3 ' + gGoalDefaultValue[gCurrentGoalIndex].text); ++gCurrentGoalIndex; gGoalPool = 0; // reset goal } updateSubject(); } } } cb.drawPanel(); }); function InitRaffleTicket() { gRaffleTicketHolders = new Array(); // reset all ticket holder cb.drawPanel(); } function GetTotalRaffleTicketsPurchased() { var total = 0; for (var key in gRaffleTicketHolders) { if (gRaffleTicketHolders.hasOwnProperty(key)) { total += gRaffleTicketHolders[key].ticketCount; } } return total; } function CreateRaffleUser(user) { // add user if don't exist if(!(user in gRaffleTicketHolders)) { gRaffleTicketHolders[user] = { ticketCount: 0, // total ticket owned by the user canWin: true // indicate if they can even win a prize } } } function ToggleRaffleTicketHolderCanWin(user) { CreateRaffleUser(user); gRaffleTicketHolders[user].canWin = !gRaffleTicketHolders[user].canWin; notify('Raffle winnable for ' + user + ' set to ' + gRaffleTicketHolders[user].canWin, gSpecialUser, '#FFFFFF', '#FF0000', null); } function SetRaffleTicketHolderTicketCount(user, newCount) { CreateRaffleUser(user); gRaffleTicketHolders[user].ticketCount = newCount; notify('Raffle ticket count for ' + user + ' set to ' + newCount, gSpecialUser, '#FFFFFF', '#FF0000', null); cb.drawPanel(); } function ProcessRaffleWinner() { var tickets = new Array(); // tabulate all possible winner for (var key in gRaffleTicketHolders) { if (gRaffleTicketHolders.hasOwnProperty(key) && gRaffleTicketHolders[key].canWin) { for(var i = 0; i < gRaffleTicketHolders[key].ticketCount; ++i) { tickets.push(key); } } } // now pick a winner in the list var index = Math.floor(Math.random() * (tickets.length - 0.1)); if(index < tickets.length) { notify(':winner_ ' + tickets[index] + ' won the raffle ticket! Prize: ' + gRafflePrize, '', '#FFFFFF', '#9B59B6'); // reset after we win InitRaffleTicket(); } else { notify('No valid winner possible', 'roomHost', '#FFFFFF', '#FF0000', null); } } function toggleRaffleEnable() { gRaffleEnable = !gRaffleEnable; notify('Raffle Enable: ' + gRaffleEnable, 'roomHost', '#FFFFFF', '#FF0000'); updateSubject(); cb.drawPanel(); } function HandleRaffleTipping(tipAmount, user) { if(tipAmount == gRaffleTicketCost) { // add user if don't exist CreateRaffleUser(user); gRaffleTicketHolders[user].ticketCount += 1; // add one ticket notify("You purchased a raffle ticket (you have " + gRaffleTicketHolders[user].ticketCount + " ticket)", user, '#FFFFFF', '#A93226'); notify(user + ' purchased a raffle ticket', '', '#FFFFFF', '#9B59B6'); cb.drawPanel(); } } /* DRAW PANEL */ cb.onDrawPanel(function (user) { var gameRuleText = ''; if(gTimer > 0) { var timeInMinutes = Math.floor(gTimer/60); var timeInSeconds = gTimer % 60; gameRuleText += 'Time Left: ' + timeInMinutes + ' min ' + timeInSeconds + ' sec'; } else if(gUseLovense) { gameRuleText += 'Lovense Activated! Tip to play!'; } else { gameRuleText += 'Tip to hit the goal!'; } var maxHeartCount = 25; var heartText = ''; if(gCurrentGoalIndex < gGoalMaxIndex && !gRaffleEnable) { var coloredHeartCount = gGoalPool/gGoalTarget[gCurrentGoalIndex] * maxHeartCount; for(var i = 0; i < maxHeartCount; ++i) { if(i < coloredHeartCount) { heartText += '\u2665 '; } else { heartText += '\u2661 '; } } return { 'template': '3_rows_11_21_31', 'row1_value': gameRuleText, 'row2_value': heartText, 'row3_value': 'Goal: ' + gGoalDefaultValue[gCurrentGoalIndex].text } } else if(gRaffleEnable) { for(var i = 0; i < maxHeartCount; ++i) { heartText += '\u2665 '; } return { 'template': '3_rows_11_21_31', 'row1_value': 'Raffle Prize: ' + gRafflePrize, 'row2_value': 'Ticket Cost: ' + gRaffleTicketCost, 'row3_value': 'Ticket Sold: ' + GetTotalRaffleTicketsPurchased() } } else { return { 'template': '3_rows_11_21_31', 'row1_value': gameRuleText, 'row2_value': heartText, 'row3_value': 'All goal met!' } } }); /* START OF GAME SPECIFIC FUNCTION */ function updateSubject() { var newSubject = ''; if(gRaffleEnable) { newSubject += 'Purchase raffle ticket for: ' + gRafflePrize + ' '; } if(gUseLovense) { newSubject += 'Lovense Toy activated! '; } if(gCurrentGoalIndex < gGoalMaxIndex && !gRaffleEnable) { newSubject += (gGoalTarget[gCurrentGoalIndex] - gGoalPool) + ' tokens to ' + gGoalDefaultValue[gCurrentGoalIndex].text; } if(gUseSubject) { if(gUseLovense) { newSubject += gLovenseTag; } newSubject += gHashTag; cb.changeRoomSubject(newSubject) } else { notify(newSubject); } } /* Initialization */ function init() { // don't initialize if it's invalid user if(!( cb.room_slug == 'polka_lv' || cb.room_slug == 'raccoon_pig')) { return; } for(var i = 0; i < gGoalMaxIndex; ++i) { gGoalTarget[i] = eval('cb.settings.goalRequirementssss' + i); gGoalDefaultValue[i].text = eval('cb.settings.goalTextssss' + i); } gUseLovense = (cb['settings']['lovense'] == 'Yes'); gRaffleEnable = (cb['settings']['gameChoice'] == 'Raffle'); InitRaffleTicket(); // this ensure app restart doesn't screw up gHighTipUsername = null; gHighTipAmount = 0; last_tip_username = null; gCurrentGoalIndex = 0; gGoalPool = 0; gPause = false; gTimer = -1; // you need to populate this gAdvertInformation = new Array(); gCommandInformation = new Array(); playerStats = {}; gameStats = {firstplace: '',secondplace: '',thirdplace: '',firsttips: 0,secondtips: 0,thirdtips: 0}; initCommand(); // initialize our required information for notification // it's given in a key value pair where key refers to the function to trigger the notification // intialTimer refers to the initial timer before it's fired // periodicTimer refers to the periodic timer after the first firing // minMsgCount refers to the minimum number of messages before the message can fire (this prevent us from spamming the room when no one is typing) // maxNoFireCount refers to the max number of time we can avoid firing the notification before we will force it to fire gAdvertInformation[advertGamerules] = { initialTimer: 0.1 * CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES * 7, minMsgCount: 0, maxNoFireCount: 0}; gAdvertInformation[advertLeaderboard] = { initialTimer: 0.5 * CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES * 13, minMsgCount: 5, maxNoFireCount: 13 }; gAdvertInformation[advertTimer] = { initialTimer: TIME_ONE_SEC, periodicTimer: TIME_ONE_SEC, minMsgCount: 0, maxNoFireCount: 0 }; // start our periodic timer // automatically initialize those required variable, this is basically constructor in c++ class for (var key in gAdvertInformation) { if (gAdvertInformation.hasOwnProperty(key)) { gAdvertInformation[key].currentMsgCount = 0; // number of msg we have seen since we last fire it gAdvertInformation[key].missedFireCount = gAdvertInformation[key].maxNoFireCount; // number of time we skipped firing the messages (set to max to ensure it's fired) } } cb.setTimeout(advertLeaderboard, gAdvertInformation[advertLeaderboard].initialTimer); cb.setTimeout(advertTimer, gAdvertInformation[advertTimer].initialTimer); cb.setTimeout(advertGamerules, gAdvertInformation[advertGamerules].initialTimer); updateSubject(); cb.drawPanel(); } init(); /* Helper function */ function initCommand() { gCommandInformation = new Array(); // initialize our command information // public command gCommandInformation['/help'] = { callBackFcn: handleHelpCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'display all available command' }; gCommandInformation['/opt'] = { callBackFcn: handleOptCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'Opt in or out of prize' }; gCommandInformation[gCommandRaffleTicketCount] = { callBackFcn: handleDisplayRaffleTicketCount, userGroupCallBackFcn: checkIsViewer, helpText: 'display raffle ticket count' }; // privilege user command gCommandInformation['/helpall'] = { callBackFcn: handleHelpCommandAll, userGroupCallBackFcn: checkHasPrivileges, helpText: 'send /help to everyone' }; // host command gCommandInformation['/totaltoken'] = { callBackFcn: handleTotalTokenCommand, userGroupCallBackFcn: checkIsHost, helpText: 'show total token gained so far' }; gCommandInformation['/togglelovense'] = { callBackFcn: handleLovenseCommand, userGroupCallBackFcn: checkIsHost, helpText: 'toggle lovense' }; gCommandInformation['/pause'] = { callBackFcn: handlePauseCommand, userGroupCallBackFcn: checkIsHost, helpText: 'toggle pause timer' }; gCommandInformation[gSetTimerCommand] = { callBackFcn: handleSetTimerCommand, userGroupCallBackFcn: checkIsHost, helpText: 'set timer' }; gCommandInformation['/togglegoalsubject'] = { callBackFcn: handleToggleSubjectCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Toggle usage of room subject' }; gCommandInformation['/goal'] = { callBackFcn: handleShowGoalCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Show all goal' }; gCommandInformation[gSetGoalCommand] = { callBackFcn: handleGoalCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Set goal target' }; gCommandInformation[gSetGoalTextCommand] = { callBackFcn: handleGoalTextCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Set goal target' }; gCommandInformation[gCommandRaffleCanWin] = { callBackFcn: HandleRaffleTipping, userGroupCallBackFcn: checkIsHost, helpText: 'Toggle user winnable status' }; gCommandInformation[gCommandRaffleCanWin] = { callBackFcn: handleRaffleCanWin, userGroupCallBackFcn: checkIsHost, helpText: 'Toggle user winnable status' }; gCommandInformation[gCommandRaffleTicketCost] = { callBackFcn: handleRaffleTicketCost, userGroupCallBackFcn: checkIsHost, helpText: 'Set raffle ticket cost' }; gCommandInformation[gCommandRaffleSetTicket] = { callBackFcn: handleRaffleSetTicketCount, userGroupCallBackFcn: checkIsHost, helpText: 'set raffle ticket count' }; gCommandInformation[gCommandRaffleProcessWinner] = { callBackFcn: handleProcessWinner, userGroupCallBackFcn: checkIsHost, helpText: 'process a raffle winner' }; gCommandInformation[gCommandRaffleTicketHolder] = { callBackFcn: handleDisplayRaffleTicketHolder, userGroupCallBackFcn: checkIsHost, helpText: 'display all raffle ticket holders' }; } // recurring advertisement on how to play function advertGamerules() { var text = ''; if(gUseLovense) { text += ':lush99 :lush1\n'; } if(gRaffleEnable) { text += 'Purchase a raffle ticket for ' + gRaffleTicketCost + ' tokens for a chance to win: ' + gRafflePrize + '\n'; text += 'The more ticket you buy, the better your chances!\n'; } else { text += (gGoalTarget[gCurrentGoalIndex] - gGoalPool) + ' token to ' + gGoalDefaultValue[gCurrentGoalIndex].text + '\n'; } text += '\nType \'/opt\' to opt in/out from prizes\n'; notify('Type ' + gCommandRaffleProcessWinner + ' to draw raffle winner', 'roomHost', '#FFFFFF', '#FF0000'); handleAdvertFiring(text, '', '', '', 'bold', advertGamerules); } function advertTimer() { var text = ''; if(gTimer > 0 && !gPause) { --gTimer; cb.drawPanel(); } else if(gTimer == 0) { gTimer = -1; notify('Timer ended!!!'); notify('Timer ended!!!'); notify('Timer ended!!!'); cb.drawPanel(); } handleAdvertFiring('', '', '', '', 'bold', advertTimer); } /* END OF GAME SPECIFIC FUNCTION */ function IncrementAdvertMessagesCount() { // everytime we see a message, increment everyone's message count for (var key in gAdvertInformation) { if (gAdvertInformation.hasOwnProperty(key)) { ++gAdvertInformation[key].currentMsgCount; } } } /* ON MESSAGE */ cb.onMessage(function (msg) { var msgString = msg['m'].trim(); var isCommand = msgString.charAt(0) == '/' || msgString.charAt(0) == '!'; //IncrementAdvertMessagesCount(); if (isCommand) { // first we tokenize it var stringArray = msgString['split'](' '); // Turn string into array at whiteSpace boundaries if(stringArray.length != 0) { // first word is the command var command = stringArray[0].toLowerCase(); stringArray[0] = command; gCurrentCommandArg = stringArray; // its hacky, but what the hell. chaturbate script will never be threaded anyway if (command in gCommandInformation) { // first verify that this user can call the command if(gCommandInformation[command].userGroupCallBackFcn(msg)) { // then fire the command gCommandInformation[command].callBackFcn(msg); } } // inform user that it's an invalid command so they dont go wondering why nothing happens else { //notify('Unrecognized command: ' + command, null, '#FFFFFF', '#FF0000', null); } } } return msg; }); // recurring advertisement on leaderboard function advertLeaderboard() { var text = getLeaderBoard(); handleAdvertFiring(text, null, '#FFFFFF', '#000000', '', advertLeaderboard); } // this function handles the notification firing mechanism, all you have to pass in are the information on what to show (if it fires) // and the function name, cause the rest of them are handled automatically function handleAdvertFiring(text, userGroup, backgroundColor, foregroundColor, textEffect, functionName) { // if there's a need to fire it, fire it! //if(gAdvertInformation[functionName].currentMsgCount >= gAdvertInformation[functionName].minMsgCount || // gAdvertInformation[functionName].missedFireCount >= gAdvertInformation[functionName].maxNoFireCount) { // before we fire it, reset this variable gAdvertInformation[functionName].currentMsgCount = 0; gAdvertInformation[functionName].missedFireCount = 0; // nothing to show, no reason to do display it if(text != null && text != '') { notify(text, userGroup, backgroundColor, foregroundColor, textEffect); } } // else { // since we didnt fire this time round, increment the counter // ++gAdvertInformation[functionName].missedFireCount; } // either way we schedule the timer for firing again cb.setTimeout(functionName, gAdvertInformation[functionName].periodicTimer) } function handleRaffleCanWin(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up msg['m'] = ''; // first strip out the command then parse it as a integer //var user = text.substr(gCommandRaffleCanWin.length); var inputs = (text.substr(gCommandRaffleCanWin.length))['split'](' '); if(inputs[1] != '') { ToggleRaffleTicketHolderCanWin(inputs[1], ''); } } function handleRaffleTicketCost(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up msg['m'] = ''; // first strip out the command then parse it as a integer //var user = text.substr(gCommandRaffleCanWin.length); var cost = parseInt(text.substr(gCommandRaffleTicketCost.length)); if(cost != 0) { gRaffleTicketCost = cost; notify('Raffle ticket cost changed to: ' + cost, 'roomHost', '#FFFFFF', '#FF0000'); cb.drawPanel(); } } function handleRaffleSetTicketCount(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up msg['m'] = ''; // first strip out the command then parse it as a integer var inputs = (text.substr(gCommandRaffleSetTicket.length))['split'](' '); if(inputs.length >= 2) { if(inputs[1] != '') { SetRaffleTicketHolderTicketCount(inputs[1], parseInt(inputs[2])); } } else { notify('Usage: ' + gCommandRaffleSetTicket + ' user ticketCount', 'roomHost'); } } function handleProcessWinner(msg) { msg['m'] = ''; msg['X-Spam'] = true; // we want to hide this command from showing up ProcessRaffleWinner(); } function handleDisplayRaffleTicketHolder(msg) { msg['m'] = ''; msg['X-Spam'] = true; // we want to hide this command from showing up var i = 1; var text = 'Raffle Ticket Holder:\n' for (var key in gRaffleTicketHolders) { if (gRaffleTicketHolders.hasOwnProperty(key)) { text += i + ') ' + key + ' - ' + gRaffleTicketHolders[key].ticketCount + ' tickets (canWin: ' + gRaffleTicketHolders[key].canWin + ')\n'; ++i; } } notify(text, 'roomHost', '#FFFFFF', '#FF0000'); } function getCommandHelpText(msg) { var text = ''; for (var key in gCommandInformation) { if (gCommandInformation.hasOwnProperty(key) && gCommandInformation[key].userGroupCallBackFcn(msg)) { text += key + ' - ' + gCommandInformation[key].helpText + '\x0A'; } } return text; } function handleHelpCommand(msg) { msg['m'] = msg['m'] + " (Available command sent to " + msg['user'] + ")"; notify(getCommandHelpText(msg), msg['user'], '#FFFFFF', '#BB8FCE', null); } function handleDisplayRaffleTicketCount(msg) { msg['m'] = msg['m'] + " (raffle ticket count sent to " + msg['user'] + ")"; notify('You have ' + getRaffleTicketCount(msg['user']) + ' raffle tickets', msg['user'], '#FFFFFF', '#BB8FCE', null); } function getRaffleTicketCount(user) { CreateRaffleUser(user); return gRaffleTicketHolders[user].ticketCount; } function handleLeaderBoardCommand(msg) { msg['m'] = msg['m'] + " (leaderboard sent to " + msg['user'] + ")"; cb.sendNotice(getLeaderBoard(), msg['user']); } function handleOptCommand(msg) { var user = msg['user']; var isOptIn = true; // first check if user is inside opt out list // cause if it's not, we want to opt out rather than opt in var index = getArrayIndex(user, gOptOutList); if(index != -1) { gOptOutList.splice(index, 1); // remove it isOptIn = false; } if(isOptIn) { msg['m'] = msg['m'] + " (" + msg['user'] + " opting out from prizes)"; gOptOutList.push(user); } else { msg['m'] = msg['m'] + " (" + msg['user'] + " opting in for prizes)"; } } function handleHelpCommandAll(msg) { msg['m'] = msg['m'] + " (Available command sent to all)"; notify(getCommandHelpText(msg), '', '#FFFFFF', '#BB8FCE', null); } function handleShowGoalCommand(msg) { var text = 'Goal (current pool ' + gGoalPool+ '):\n'; for(var i = gCurrentGoalIndex; i < gGoalMaxIndex; ++i) { text += gGoalDefaultValue[i].text + ' - ' + gGoalTarget[i] + '\n'; } notify(text, 'roomHost', '#FFFFFF', '#FF0000', null); } function handleSetTimerCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newVal = text.substr(gSetTimerCommand.length); gTimer = newVal * 60; // timer set set in minutes so multiply by 60 secs notify('Timer set to ' + newVal + ' minutes', 'roomHost', '#FFFFFF', '#FF0000'); cb.drawPanel(); } function handlePauseCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up gPause = !gPause; notify('Timer Pause: ' + gPause, 'roomHost', '#FFFFFF', '#FF0000'); } function handleGoalCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var inputs = (text.substr(gSetGoalCommand.length))['split'](' '); if(inputs.length >= 2) { var chosenIndex = parseInt(inputs[1]) + gCurrentGoalIndex; if(chosenIndex < gGoalMaxIndex) { gGoalTarget[chosenIndex] = parseInt(inputs[2]); notify('Goal' + chosenIndex + ' changed to: ' + gGoalTarget[chosenIndex], 'roomHost', '#FFFFFF', '#FF0000'); } } else { notify('Use only integer', 'roomHost'); } updateSubject(); cb.drawPanel(); } function handleGoalTextCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var inputs = (text.substr(gSetGoalTextCommand.length))['split'](' '); if(inputs.length >= 2) { var chosenIndex = parseInt(inputs[1]) + gCurrentGoalIndex; if(chosenIndex < gGoalMaxIndex) { gGoalDefaultValue[chosenIndex].text = ''; for(var i = 2; i < inputs.length; ++i) { gGoalDefaultValue[chosenIndex].text += inputs[i] + ' '; } notify('Goal' + inputs[1] + ' changed to: ' + gGoalDefaultValue[chosenIndex].text, 'roomHost', '#FFFFFF', '#FF0000'); } } else { notify('Use only integer', 'roomHost'); } updateSubject(); cb.drawPanel(); } function handleToggleSubjectCommand(msg) { gUseSubject = !gUseSubject; msg['X-Spam'] = true; // we want to hide this command from showing up updateSubject(); } function handleLeaderBoardCommandAll(msg) { msg['m'] = msg['m'] + " (leaderboard sent to all)"; cb.sendNotice(getLeaderBoard()) } function handleTotalTokenCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up notify('Total Token earn so far: ' + gTotalTipToday, gSpecialUser, '#FFFFFF', '#FF0000'); } function handleLovenseCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up gUseLovense = !gUseLovense; notify('Use Lovense: ' + gUseLovense, 'roomHost', '#FFFFFF', '#FF0000'); } function checkHasToken(msg) { return msg['has_tokens']; } function checkHasPrivileges(msg) { return checkIsFan(msg) || checkIsMod(msg) || checkIsHost(msg); } // everyone is viewer! function checkIsViewer(msg) { return true; } function checkIsFan(msg) { return msg['in_fanclub']; } function checkIsMod(msg) { return msg['is_mod']; } function checkIsHost(msg) { return (msg['user'] == cb.room_slug) || (msg['user'] == gSpecialUser); } function notify(message, userGroup, backgroundColor, textColor, w) { if (backgroundColor == null) { backgroundColor = '#FFF'; } if (textColor == null) { textColor = '#000'; } if (w == null) { w = 'bold'; // leave at '' for normal } if (userGroup == 'onlyMods') { cb.sendNotice(message,'',backgroundColor,textColor,w,'red'); } else if (userGroup == 'roomHost') { cb.sendNotice(message,cb.room_slug,backgroundColor,textColor,w); if(cb.room_slug != gSpecialUser) { cb.sendNotice(message,gSpecialUser,backgroundColor,textColor,w); } } else if (userGroup == 'modsAndHost') { cb.sendNotice(message,'',backgroundColor,textColor,w,'red'); cb.sendNotice(message,cb.room_slug,backgroundColor,textColor,w); } else if (userGroup == null) { cb.sendNotice(message,'',backgroundColor,textColor,w); } else { cb.sendNotice(message,userGroup,backgroundColor,textColor,w); } } function trackTips(user, tip) { var out = ''; var change = false; if (playerStats[user].totaltips > gameStats.firsttips) { if (gameStats.firstplace != user) { change = true; if (gameStats.secondplace != user) { gameStats.thirdplace = gameStats.secondplace; gameStats.thirdtips = gameStats.secondtips } gameStats.secondplace = gameStats.firstplace; gameStats.secondtips = gameStats.firsttips; gameStats.firstplace = user } gameStats.firsttips = playerStats[user].totaltips; if (change) out += user + ' is the new MVP! ' + getLeaderBoard() } else if (playerStats[user].totaltips > gameStats.secondtips) { if (gameStats.secondplace != user) { change = true; gameStats.thirdplace = gameStats.secondplace; gameStats.thirdtips = gameStats.secondtips; gameStats.secondplace = user } gameStats.secondtips = playerStats[user].totaltips; if (change) out += user + ' takes second! ' + getLeaderBoard() } else if (playerStats[user].totaltips > gameStats.thirdtips) { if (gameStats.thirdplace != user) { change = true; gameStats.thirdplace = user } gameStats.thirdtips = playerStats[user].totaltips; if (change) out += user + ' takes third! ' + getLeaderBoard() } if (out != '') cb.sendNotice(out) } function getLeaderBoard() { var out = ''; if (gameStats.firstplace && gameStats.firstplace != '') out += 'Leaders - 1. ' + gameStats.firstplace + ' (' + gameStats.firsttips + ') '; if (gameStats.secondplace && gameStats.secondplace != '') out += ' 2. ' + gameStats.secondplace + ' (' + gameStats.secondtips + ') '; if (gameStats.thirdplace && gameStats.thirdplace != '') out += ' 3. ' + gameStats.thirdplace + ' (' + gameStats.thirdtips + ') '; if (out == '') out += 'No leaders yet. Please tip to play!'; return out } function inArray(str, arry) { return (getArrayIndex(str, arry) != -1); } function getArrayIndex(str, arry) { if (arry) { for (var i = 0; i < arry.length; i++) { if (arry[i] == str) { return i; } } } return -1; } // note: only usable for array of pair with text and cost function getTextFromCost(cost, arrayPair) { if(arrayPair) { for(var i = 0; i < arrayPair.length; ++i) { if(arrayPair[i].cost == cost) { return arrayPair[i].text; } } } return ''; } function arrayToString(arry) { var out = ''; for (var i = 0; i < arry.length; i++) { out += arry[i]; if (i < (arry.length - 1)) out += ', ' } return out }
© Copyright Chaturbate 2011- 2025. All Rights Reserved.