Apps Home
|
Create an App
MvN1
Author:
armincheggg
Description
Source Code
Launch App
Current Users
Created by:
Armincheggg
//////////////////////////////////////////// //Wheel of Fortune (Application) // // // a combination of Auto-Reset Tip Goal, Wheel of Fortune // // //////////////////////////////////////////// // Based loosely on code from: // Wheel Of Fortune by Wildtimxxx // Auto-Reset Tip Goal by Wildtimxxx //////////////////////////////////////////// // Wheel Variables var total_tipped = 0; var multiMessage = 'Disabled!'; var lastspinby = 'nobody'; var GoalTipTracking = []; var RewardsTracking = []; var RewardsTrackingCount = 0; // Auto-Reset Tip Goal Variables var times_goal_reached = 0; var last_time_goal_reached = null; var current_goal_tipped = 0; cb.settings_choices = [ {name: 'autogoalresetactive', type: 'choice', label: 'Auto-Reset Tip Goal', choice1: 'Enabled', choice2: 'Disabled', defaultValue: 'Disabled'}, {name: 'tokens', type: 'int', minValue: 1, defaultValue: 100, label: 'Token Goal'}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255, label: 'Goal Description'}, {name: 'goalspinMvNwheel', type: 'choice', label: 'Spin MvN Wheel at every goal', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, {name: 'tokensprogress', type: 'int', minValue: 0, defaultValue: 0, label: 'Tokens in Jar from start'}, {name: 'skiptipamounts', type: 'str', minLength: 0, maxLength: 1024, label: 'Tip amounts not to count (eg. \'599,666,999,1234,5000\')', required: false}, {name: 'MvNwheelactive', type: 'choice', label: 'MvNWheel of Fortune', choice1: 'Enabled', choice2: 'Disabled', defaultValue: 'Disabled'}, {name: 'announcewheelonenter', type: 'choice', label: 'Announce MvN Wheel when blues enter the room', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, {name:'cost_per_spin', type:'int', minValue:1, maxValue:999, defaultValue:50, label: 'Cost per Spin of the MvNWheel (1-999)'}, {name:'advertise_in_chat', type:'int', minValue:0, maxValue:999, defaultValue:10, label: 'How often to advertise MvNWheel: (min) (0=never)'}, {name:'multispin_count', type:'int', minValue:1, maxValue:999, defaultValue:5, label: 'How many Multi-Spins to allow? (1-999)'}, {name:'wheelemailtxt', type: 'str', minLength: 1, maxLength: 255, label: 'Text to ask for email:', defaultValue: 'USERNAME please write your email-address in a 1 token tip-note'}, {name:'pos1', type:'str', minLength: 1, maxLength: 255, label: 'Reward 1', required: false}, {name: 'pos1action', type: 'choice', label: 'Reward 1 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos2', type:'str', minLength: 1, maxLength: 255, label: 'Reward 2', required: false}, {name: 'pos2action', type: 'choice', label: 'Reward 2 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos3', type:'str', minLength: 1, maxLength: 255, label: 'Reward 3', required: false}, {name: 'pos3action', type: 'choice', label: 'Reward 3 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos4', type:'str', minLength: 0, maxLength: 255, label: 'Reward 4', required: false}, {name: 'pos4action', type: 'choice', label: 'Reward 4 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos5', type:'str', minLength: 0, maxLength: 255, label: 'Reward 5', required: false}, {name: 'pos5action', type: 'choice', label: 'Reward 5 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos6', type:'str', minLength: 0, maxLength: 255, label: 'Reward 6', required: false}, {name: 'pos6action', type: 'choice', label: 'Reward 6 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos7', type:'str', minLength: 0, maxLength: 255, label: 'Reward 7', required: false}, {name: 'pos7action', type: 'choice', label: 'Reward 7 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos8', type:'str', minLength: 0, maxLength: 255, label: 'Reward 8', required: false}, {name: 'pos8action', type: 'choice', label: 'Reward 8 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos9', type:'str', minLength: 0, maxLength: 255, label: 'Reward 9', required: false}, {name: 'pos9action', type: 'choice', label: 'Reward 9 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos10', type:'str', minLength: 0, maxLength: 255, label: 'Reward 10', required: false}, {name: 'pos10action', type: 'choice', label: 'Reward 10 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos11', type:'str', minLength: 0, maxLength: 255, label: 'Reward 11', required: false}, {name: 'pos11action', type: 'choice', label: 'Reward 11 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos12', type:'str', minLength: 0, maxLength: 255, label: 'Reward 12', required: false}, {name: 'pos12action', type: 'choice', label: 'Reward 12 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos13', type:'str', minLength: 0, maxLength: 255, label: 'Reward 13', required: false}, {name: 'pos13action', type: 'choice', label: 'Reward 13 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos14', type:'str', minLength: 0, maxLength: 255, label: 'Reward 14', required: false}, {name: 'pos14action', type: 'choice', label: 'Reward 14 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos15', type:'str', minLength: 0, maxLength: 255, label: 'Reward 15', required: false}, {name: 'pos15action', type: 'choice', label: 'Reward 15 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos16', type:'str', minLength: 0, maxLength: 255, label: 'Reward 16', required: false}, {name: 'pos16action', type: 'choice', label: 'Reward 16 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos17', type:'str', minLength: 0, maxLength: 255, label: 'Reward 17', required: false}, {name: 'pos17action', type: 'choice', label: 'Reward 17 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos18', type:'str', minLength: 0, maxLength: 255, label: 'Reward 18', required: false}, {name: 'pos18action', type: 'choice', label: 'Reward 18 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos19', type:'str', minLength: 0, maxLength: 255, label: 'Reward 19', required: false}, {name: 'pos19action', type: 'choice', label: 'Reward 19 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos20', type:'str', minLength: 0, maxLength: 255, label: 'Reward 20', required: false}, {name: 'pos20action', type: 'choice', label: 'Reward 20 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos21', type:'str', minLength: 0, maxLength: 255, label: 'Reward 21', required: false}, {name: 'pos21action', type: 'choice', label: 'Reward 21 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos22', type:'str', minLength: 0, maxLength: 255, label: 'Reward 22', required: false}, {name: 'pos22action', type: 'choice', label: 'Reward 22 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos23', type:'str', minLength: 0, maxLength: 255, label: 'Reward 23', required: false}, {name: 'pos23action', type: 'choice', label: 'Reward 23 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos24', type:'str', minLength: 0, maxLength: 255, label: 'Reward 24', required: false}, {name: 'pos24action', type: 'choice', label: 'Reward 24 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos25', type:'str', minLength: 0, maxLength: 255, label: 'Reward 25', required: false}, {name: 'pos25action', type: 'choice', label: 'Reward 25 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos26', type:'str', minLength: 0, maxLength: 255, label: 'Reward 26', required: false}, {name: 'pos26action', type: 'choice', label: 'Reward 26 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos27', type:'str', minLength: 0, maxLength: 255, label: 'Reward 27', required: false}, {name: 'pos27action', type: 'choice', label: 'Reward 27 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos28', type:'str', minLength: 0, maxLength: 255, label: 'Reward 28', required: false}, {name: 'pos28action', type: 'choice', label: 'Reward 28 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos29', type:'str', minLength: 0, maxLength: 255, label: 'Reward 29', required: false}, {name: 'pos29action', type: 'choice', label: 'Reward 29 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos30', type:'str', minLength: 0, maxLength: 255, label: 'Reward 30', required: false}, {name: 'pos30action', type: 'choice', label: 'Reward 30 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos31', type:'str', minLength: 0, maxLength: 255, label: 'Reward 31', required: false}, {name: 'pos31action', type: 'choice', label: 'Reward 31 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos32', type:'str', minLength: 0, maxLength: 255, label: 'Reward 32', required: false}, {name: 'pos32action', type: 'choice', label: 'Reward 32 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos33', type:'str', minLength: 0, maxLength: 255, label: 'Reward 33', required: false}, {name: 'pos33action', type: 'choice', label: 'Reward 33 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos34', type:'str', minLength: 0, maxLength: 255, label: 'Reward 34', required: false}, {name: 'pos34action', type: 'choice', label: 'Reward 34 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'}, {name:'pos35', type:'str', minLength: 0, maxLength: 255, label: 'Reward 35', required: false}, {name: 'pos35action', type: 'choice', label: 'Reward 35 action', choice1: 'No Action', choice2: 'Track Reward', choice3: 'Request email in tip note', choice4: 'Track and Request email', defaultValue: 'No Action'} ]; var temp = new Array(cb.settings.pos1,cb.settings.pos2,cb.settings.pos3,cb.settings.pos4,cb.settings.pos5,cb.settings.pos6,cb.settings.pos7,cb.settings.pos8,cb.settings.pos9,cb.settings.pos10,cb.settings.pos11,cb.settings.pos12,cb.settings.pos13,cb.settings.pos14,cb.settings.pos15,cb.settings.pos16,cb.settings.pos17,cb.settings.pos18,cb.settings.pos19,cb.settings.pos20,cb.settings.pos21,cb.settings.pos22,cb.settings.pos23,cb.settings.pos24,cb.settings.pos25,cb.settings.pos26,cb.settings.pos27,cb.settings.pos28,cb.settings.pos29,cb.settings.pos30,cb.settings.pos31,cb.settings.pos32,cb.settings.pos33,cb.settings.pos34,cb.settings.pos35); var tempp = new Array(cb.settings.pos1action,cb.settings.pos2action,cb.settings.pos3action,cb.settings.pos4action,cb.settings.pos5action,cb.settings.pos6action,cb.settings.pos7action,cb.settings.pos8action,cb.settings.pos9action,cb.settings.pos10action,cb.settings.pos11action,cb.settings.pos12action,cb.settings.pos13action,cb.settings.pos14action,cb.settings.pos15action,cb.settings.pos16action,cb.settings.pos17action,cb.settings.pos18action,cb.settings.pos19action,cb.settings.pos20action,cb.settings.pos21action,cb.settings.pos22action,cb.settings.pos23action,cb.settings.pos24action,cb.settings.pos25action,cb.settings.pos26action,cb.settings.pos27action,cb.settings.pos28action,cb.settings.pos29action,cb.settings.pos30action,cb.settings.pos31action,cb.settings.pos32action,cb.settings.pos33action,cb.settings.pos34action,cb.settings.pos35action); var rewards = new Array(); var rewardsaction = new Array(); for (var i = 0; i<temp.length; i++) { if(temp[i] != ''){ rewards.push(temp[i]); rewardsaction.push(tempp[i]); } } if (cb.settings.multispin_count > 1){multiMessage = 'Enabled! x ' + cb.settings.multispin_count;} if (rewards.length==0){cb.settings.ponywheelactive="Disabled";} function showStartupMessage(userName){ if (cb.settings.MvNWheelactive != 'Enabled'){return;} var lsb=lastspinby.substring(0, 14); var out = ''; out += repeatStr('\u2014',31) + '\n'; out += ' MvNCrush Wheel of Fortune ' + '\n'; out += repeatStr('\u2014',31) + '\n'; out += '\u203a' + ' Spin Cost: ' + cb.settings.cost_per_spin + ' tokens' + '\n'; out += '\u203a' + ' Multi-Spin: ' + multiMessage + '\n'; out += '\u203a' + ' Last Spin by: ' + lsb + '\n' + '\n'; for(var x = 0; x < rewards.length; x++) { out += ' Reward ' + (x + 1) + ': ' + rewards[x] + '\n'; } out += repeatStr('\u2014',31) + '\n'; out += ' Good Luck and Have Fun. ' + '\n'; out += repeatStr('\u2014',31); if (userName.length >0){ cb.chatNotice(out, userName); } else { cb.chatNotice(out); out = 'You (the broadcaster) can type \'/spin UserName\' to force a spin' + '\n'; out += 'You and your Moderators can type \'/rewards all\' to send Rewards List to all users' + '\n'; out += 'You and your Moderators can type \'/help\' to get a list of available commands' + ''; cb.chatNotice(out, cb.room_slug, '', '#ff0000', 'bold'); } } function repeatStr(string, counter){ var temp = ''; for (x=1; x<=counter; x++){temp += string;} return temp; } function spinWheel(userName, forced) { if ((cb.settings.MvNWheelactive != 'Enabled') && (forced!=1)){return;} var out = ''; if (forced == 0){lastspinby=userName;} if (userName == 'forced'){userName = cb.room_slug;} out += repeatStr('\u2014',30) + '\n'; out += '\u203a' + ' Spinning the MvNWheel for ' + userName + '\n'; var randomnumber = Math.floor(Math.random()*(rewards.length)); out += '\u203a' + ' Stopped on: ' + rewards[randomnumber] + '\n'; out += repeatStr('\u2014',30); cb.chatNotice(out, '', '#dfffb2', '', 'bold'); if ((rewardsaction[randomnumber] == "Request email in tip note") || (rewardsaction[randomnumber] == "Track and Request email")){ if (userName != cb.room_slug){ var message = cb.settings.wheelemailtxt.replace('USERNAME', userName); cb.chatNotice(message, userName, '', '#FF0000', 'bolder'); cb.chatNotice('\'Request email\'-message have been sent to ' + userName, cb.room_slug, '', '#0000FF', 'normal'); } } if ((rewardsaction[randomnumber] == "Track Reward") || (rewardsaction[randomnumber] == "Track and Request email")){ TrackReward(userName, rewards[randomnumber]); } } function TrackReward(userName, rewardwon){ RewardsTrackingCount+=1; RewardsTracking[RewardsTrackingCount]=rewardwon + " [" + userName + "]"; cb.chatNotice('Tracking Reward. type \'/tracklist\' to list the tracking list.', cb.room_slug, '', '#0000FF', 'bolder'); } function TrackListRewards(){ var out = ""; for (var i = 1; i<RewardsTracking.length; i++) { if(typeof RewardsTracking[i] !== 'undefined'){ out += '#' + i + ': ' + RewardsTracking[i] + '\n'; } } if (out!=''){ out = repeatStr('\u2014',30) + '\n' + 'Rewards Tracking' + '\n' + repeatStr('\u2014',30) + '\n' + out; out += '\n' + 'To remove #154 type \'/untrack 154\'.' + '\n' + repeatStr('\u2014',30); cb.chatNotice(out, cb.room_slug, '', '', 'normal'); } else { cb.chatNotice("Tracking list is empty!", cb.room_slug, '', '#0000FF', 'bold'); } } function TrackRemove(id){ if (typeof RewardsTracking[id] !== 'undefined'){ RewardsTracking[id]=undefined; cb.chatNotice('#' + id + ' removed from tracking.', cb.room_slug, '', '#0000FF', 'bolder'); TrackListRewards(); } else { cb.chatNotice('#' + id + ' does not exist.', cb.room_slug, '', '#FF0000', 'bolder'); } } function GoalSpins(gospin){ for (var i = 1; i <= gospin; i++){ // Now who should we spin for? GoalTipTracking.sort(orderByTipsDescending); var UserSpinnerName = GoalTipTracking[0].name; var UserSpinnerTips = GoalTipTracking[0].tips; if (UserSpinnerTips < cb.settings.tokens){ GoalTipTracking.splice(0, 1); } else { for (var i in GoalTipTracking) { if (GoalTipTracking[i].name == UserSpinnerName) { GoalTipTracking[i].tips -= cb.settings.tokens; } } } spinWheel(UserSpinnerName, 0); } } cb.onTip(function (tip) { var skiptip = 0; // Is this a skipped amount? if (cb.settings.skiptipamounts.length > 0){ var skiparray = []; skiparray = cb.settings.skiptipamounts.split(','); for (var i = 0; i < skiparray.length; i++) { if (tip['amount'] == parseInt(skiparray[i], 10)){skiptip = 1;} } if (skiptip){ cb.chatNotice('Tip from ' + tip['from_user'] + ' [' + tip['amount'] + '] did not count towards room goal, as per your settings.', cb.room_slug, '', '#ff0000', 'bold'); } } // MvNWheel if ((cb.settings.MvNWheelactive == 'Enabled') && (skiptip == 0)){ var tipJar = tip['amount']; var userName = tip['from_user']; var spinCount = 0; // While the Tip Jar has enough doe for a spin while(tipJar >= cb.settings.cost_per_spin){ // And If We Have A SpinCount Left... if(spinCount < (cb.settings.multispin_count)){ // Spin The Wheel. // if(spinCount > 0){ // cb.chatNotice('! Multi-Spin Activated !'); // } spinWheel(userName, 0); sleep(250); } tipJar -= cb.settings.cost_per_spin; spinCount++; } total_tipped += parseInt(tip['amount']); cb.drawPanel(); if (spinCount>0){ cb.chatNotice('Thank you ' + userName + ', for playing the MvNWheel', userName, '', '#0000FF', 'bolder'); } } // Auto-Reset Goal if ((cb.settings.autogoalresetactive == 'Enabled') && (skiptip == 0)){ var tipped = tip['amount']; // Trying to avoid dual spins for the same tokens // Spin cost of 100 // Goal at 100 // If someone tips 200, we don't want 4 spins, only 2 if ((spinCount>0) && (cb.settings.goalspinMvNWheel == 'Yes') && (cb.settings.MvNWheelactive == 'Enabled')){ current_goal_tipped += cb.settings.cost_per_spin * spinCount; tipped -= cb.settings.cost_per_spin * spinCount; if (current_goal_tipped >= cb.settings.tokens) { goalReached('silent'); } } // if spin on goal is active, we want to somewhat track the tippers if ((cb.settings.goalspinMvNWheel == 'Yes') && (cb.settings.MvNWheelactive == 'Enabled') && (cb.settings.autogoalresetactive == 'Enabled')){ TrackGoalTipper(tip['from_user'], tipped); } current_goal_tipped += tipped; if (current_goal_tipped >= cb.settings.tokens) { goalReached(); } update_subject(); cb.drawPanel(); } }); cb.onEnter(function(user) { if ((cb.settings.announcewheelonenter == 'Yes') && (cb.settings.MvNWheelactive == 'Enabled')){ if (user['has_tokens']){ showStartupMessage(user['user']); } } }); cb.onMessage(function (msg) { var userName = msg['user']; if ((cb.settings.MvNWheelactive == 'Enabled') && (msg['m'] == '/rewards')){ // MvNWheel Send rewards list to single user (all users) ///////////////////////////// showStartupMessage(userName); } else if ((cb.settings.MvNWheelactive == 'Enabled') && ((msg['m'] == '/rewards all') && ((msg['is_mod']) || (userName == cb.room_slug)))){ // MvNWheel Send rewards list to all (Broadcaster & Moderators) ///////////////////////////// showStartupMessage(''); cb.chatNotice('You sent the Rewards List to everybody', userName, '', '#0000FF', 'bolder'); msg['m']='Sending the Rewards List to everybody'; } else if((msg['m'].substring(0,5) == '/spin') && (userName == cb.room_slug)){ // MvNWheel Spin by the Broadcaster (Broadcaster) ///////////////////////////// // Any specific user? if (msg['m'].length > 6){ var forceduser = msg['m'].substr(6); spinWheel(forceduser, 1); } else { spinWheel('forced', 1); } msg['m']='Spinning the MvNWheel'; } else if((msg['m'] == '/help') && ((msg['is_mod']) || (userName == cb.room_slug))){ // MvNWheel Help (Broadcaster & Moderators) ///////////////////////////// if (msg['user'] == cb.room_slug){ showHelp('broadcaster', userName); } else { showHelp('moderator', userName); } msg['X-Spam'] = true; } else if((msg['m'].substring(0,11) == '/addtokens ') && (userName == cb.room_slug)){ // Add tokens to room total (Broadcaster) ///////////////////////////// msg['X-Spam'] = true; if (msg['m'].substring(0,12) == '/addtokens -'){ if (msg['m'].length > 12){ TipAddRemove(parseInt(msg['m'].substr(12),10), 'remove'); } else { cb.chatNotice('/addtokens command failed (no amount?)', userName, '', '#FF0000', 'bold'); } } else { if (msg['m'].length > 11){ TipAddRemove(parseInt(msg['m'].substr(11),10), 'add'); } else { cb.chatNotice('/addtokens command failed (no amount?)', userName, '', '#FF0000', 'bold'); } } } else if((msg['m'].substring(0,9) == '/untrack ') && (userName == cb.room_slug)){ // MvNWheel Remove Reward from the trackinglist (Broadcaster) ///////////////////////////// msg['X-Spam'] = true; if (msg['m'].length > 9){ TrackRemove(parseInt(msg['m'].substr(9),10)); } } else if((msg['m'].substring(0,10) == '/tracklist') && (userName == cb.room_slug)){ // MvNWheel List Rewards on the trackinglist (Broadcaster) ///////////////////////////// msg['X-Spam'] = true; TrackListRewards(); } else { return msg; } }); function TipAddRemove(amount, action){ if (amount < 1){ cb.chatNotice('command failed (no or illegal amount!)', cb.room_slug, '', '#FF0000', 'bold'); return; } if (action=='remove'){ current_goal_tipped -= amount; cb.chatNotice(amount + ' tokens subtracted from room goal', cb.room_slug, '', '#FF0000', 'bold'); } if (action=='add'){ current_goal_tipped += amount; cb.chatNotice(amount + ' tokens added to room goal', cb.room_slug, '', '#FF0000', 'bold'); } while (current_goal_tipped >= cb.settings.tokens){ current_goal_tipped-=cb.settings.tokens; times_goal_reached+=1; last_time_goal_reached = new Date(); } while (current_goal_tipped < 0){ current_goal_tipped+=cb.settings.tokens; times_goal_reached-=1; } if (times_goal_reached<0){ current_goal_tipped=0; times_goal_reached=0; } update_subject(); cb.drawPanel(); } function showHelp(type, userName){ var out =""; out += repeatStr('\u2014',31) + '\n'; out += 'MvNCrush Wheel of Fortune ' + '\n'; out += repeatStr('\u2014',31) + '\n'; if (type=="broadcaster"){ out += '\'/spin UserName\' to force a spin' + '\n'; out += '\'/addtokens xxx\' to add xxx tokens to the total room goal' + '\n'; out += '\'/addtokens -xxx\' to remove xxx tokens from the total room goal' + '\n'; out += '\'/tracklist\' to list the tracked rewards' + '\n'; out += '\'/untrack xxx\' to remove #xxx from the tracking list' + '\n'; } out += '\'/rewards all\' to send Rewards List to all users' + '\n'; out += '\'/help\' to get a list of available commands' + '\n'; cb.chatNotice(out, userName, '', '#FF0000', 'bold'); } cb.onDrawPanel(function(user) { if ((cb.settings.MvNWheelactive == 'Enabled') && (cb.settings.autogoalresetactive != 'Enabled')){ var lsb=lastspinby.substring(0, 14); return { 'template': '3_rows_of_labels', 'row1_label': 'Spin Cost / Total Tips: ', 'row1_value': cb.settings.cost_per_spin + ' / ' + total_tipped, 'row2_label': 'Last Spin by:', 'row2_value': lsb, 'row3_label': 'Multi-Spin:', 'row3_value': multiMessage }; } else if (cb.settings.autogoalresetactive == 'Enabled'){ if (times_goal_reached == 0) { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': 'Never' }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': '' + Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' minutes ago' }; } } }); // Advertise MvNWheel in the Chat function advert() { var lsb=lastspinby.substring(0, 14); var out =''; out += 'MvNCrush Wheel of Fortune!' + ' \u00bb Last Spin by: ' + lsb + '\n'; out += 'Tip ' + cb.settings.cost_per_spin + ' to Play \u2022 Type \'/rewards\' to see rewards'; cb.chatNotice(out, '', '', '#0000ff', 'normal'); cb.setTimeout(advert, (cb.settings.advertise_in_chat * 60000)); } // Refresh Auto-Goal panel (below video) function updatepanel() { cb.setTimeout(updatepanel, 20000); cb.drawPanel(); } if (cb.settings.MvNWheelactive == 'Enabled'){ showStartupMessage(''); if (cb.settings.advertise_in_chat > 0){ cb.setTimeout(advert, (cb.settings.advertise_in_chat * 60000)); } } if (cb.settings.autogoalresetactive == 'Enabled'){ if (cb.settings.tokensprogress > 0){ current_goal_tipped += cb.settings.tokensprogress; if (current_goal_tipped >= cb.settings.tokens){ goalReached('silent'); } } update_subject(); updatepanel(); } function update_subject() { var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; cb.changeRoomSubject(new_subject); } function goalReached(silent) { var out = ''; var gospin=0; last_time_goal_reached = new Date(); var curr_times_reached = Math.floor(current_goal_tipped / cb.settings.tokens); for (var i = 0; i < curr_times_reached; i++) { times_goal_reached++; current_goal_tipped -= cb.settings.tokens; if (out.length > 0){out += '\n';} out += "Goal was reached for the " + getNumberString(times_goal_reached) + " time!"; if (cb.settings.goalspinMvNWheel == 'Yes'){gospin+=1;} } if (silent == 'silent'){out=''; gospin=0;} if (out.length > 0){ cb.chatNotice(out, '', '', '', 'bolder'); if (gospin > 0){ GoalSpins(gospin); } } } function getNumberString(number) { var numberString = null; if (number == 1) { numberString = "1st"; } else if (number == 2) { numberString = "2nd"; } else if (number == 3) { numberString = "3rd"; } else { numberString = "" + number + "th"; } return (numberString); } function tips_remaining() { var r = cb.settings.tokens - current_goal_tipped; if (r < 0) { return 0; } else { return r; } } function TrackGoalTipper(userName, tipAmount){ if (cb.settings.goalspinMvNWheel != 'Yes'){return;} var amountchanged = 0; // Just trying to make it a bit fair, by spinning for the user that has tipped the most (not keeping an HARD eye on it, just loosely) for (var i in GoalTipTracking) { if (GoalTipTracking[i].name == userName) { GoalTipTracking[i].tips += tipAmount; amountchanged=1; } } if (amountchanged == 0){ GoalTipTracking.push({ name: userName, tips: tipAmount }); } } function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } function orderByTipsDescending(a, b) { if (a.tips == b.tips) { return 0; } else if (a.tips < b.tips) { return 1; } return -1; }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.