Apps Home
|
Create an App
Guess the LUCKY number!
Author:
test01
Description
Source Code
Launch App
Current Users
Created by:
Test01
var guessedNumbers = []; var winner = false; var amount; cb.onTip(function (tip) { var minNumber = cb.settings.minNumber; var maxNumber = cb.settings.maxNumber; var found = false; if(winner != true){ if (tip.amount == cb.settings.guessNumber) { cb.chatNotice("YAY you've found the right number we will PM you XO ! " + tip.from_user + " !"); cb.chatNotice("The number was : " + tip.amount); winner = true; } else { for(var i = 0; i < guessedNumbers.length; i++){ if(guessedNumbers[i] == tip.amount){ found = true; } } if(found != true){ if(tip.amount <= maxNumber && tip.amount >= minNumber){ guessedNumbers.push(tip.amount); guessedNumbers.sort(function(a,b){ return a-b; }); } } if(tip.amount <= maxNumber && tip.amount >= minNumber){ cb.chatNotice("OOPS! Not the lucky number keep guessing ! Numbers attempted : "); cb.chatNotice(guessedNumbers.toString()); } } } else{ cb.chatNotice("We've got a winner already ! Thanks for tipping. "); } } ); function update_subject(minNumber, maxNumber, prize) { var new_subject = 'Tip Guess from ' + minNumber + " to " + maxNumber + ". To win : " + prize; cb.changeRoomSubject(new_subject); } function setSettings(){ cb.settings_choices = [ { name:'minNumber', type:'int', minValue: 1, default: 1, label: "Minimum value to guess" }, { name:'maxNumber', type:'int', minValue: 1, default: 1, label: "Maximum value to guess" }, { name:'guessNumber', type:'int', minValue: 1, default: 1, label: "Number to guess" }, { name:'prize', type:'str', label: "Prize to win" } ]; } function init() { setSettings(); update_subject(cb.settings.minNumber, cb.settings.maxNumber, cb.settings.prize); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.