Bots Home
|
Create an App
Strength
Author:
lustang
Description
Source Code
Launch Bot
Current Users
Created by:
Lustang
cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, label: 'How much to play the highest number?', defaultValue: 1}, {name: 'level_1', type: 'int', label: 'Level 1', defaultValue: 5}, {name: 'level_2', type: 'int', label: 'Level 2', defaultValue: 10}, {name: 'prize_1', type: 'str', label: 'First prize', defaultValue: 'First Prize'}, {name: 'prize_2', type: 'str', label: 'Second prize', defaultValue: 'Second Prize'}, {name: 'prize_3', type: 'str', label: 'Second prize', defaultValue: 'Third Prize'}, {name: 'consolation_prize_1', type: 'str', label: 'Consolation Prize 1', defaultValue: 'AA'}, {name: 'consolation_prize_2', type: 'str', label: 'Consolation Prize 2', defaultValue: 'BB'}, ]; var NUMBERS = 20; var LEVEL_0 = 0; var LEVEL_1 = 1; var LEVEL_2 = 2; var TA_USER = 0; var TA_NUMTIPS = 1; var TA_LVL = 2; var tipperArray = new Array; var numTippers = 0; var price = cb.settings.tokens; function tipperArrayPopulate(user) { tipperArray[numTippers] = new Array; tipperArray[numTippers][TA_USER] = user; tipperArray[numTippers][TA_NUMTIPS] = 0; tipperArray[numTippers][TA_LVL] = LEVEL_0; numTippers++; } function findTipper(user) { // Find the index of the user for(var i = 0; i < tipperArray.length; i++) { if (tipperArray[i][TA_USER] == user) { break; // User found } } // User not in array, add him if (i == tipperArray.length) { tipperArrayPopulate(user); findTipper(user); } return i; } cb.onTip(function(tip) { var tipper = tipperArray[findTipper(tip['from_user'])]; // Add tip to the user tipper[TA_NUMTIPS] += parseInt(tip['amount']); cb.log('Tot ' + tipper[TA_NUMTIPS]); var newLevelReached = false; if (tipper[TA_NUMTIPS] >= cb.settings.level_1) { tipper[TA_LVL] = LEVEL_2; newLevelReached = LEVEL_2; cb.log('Reached 2'); } else if (tipper[TA_NUMTIPS] >= cb.settings_level_2) { tipper[TA_LVL] = LEVEL_3; newLevelReached = LEVEL_3; cb.log('Reached 3'); } // If the user has reached a new level if (newLevelReached) { var userMsg = '| ' + tip['from_user'] + ' has reached Level ' + newLevelReached + '! |'; var dashes = ''; for (var i = 0; i < userMsg.length; i++) { dashes += '-'; } var msg = dashes + '\n'; msg += tip['from_user'] + ' has reached Level ' + newLevelReached + '!' + '\n' msg += dashes + '\n'; cb.sendNotice(msg, '', '#C8E6C9', '#000', 'bold'); } // Check to see have to play the game if (tip['amount'] >= price) { var dielUser = Math.floor(Math.random() * NUMBERS) + 1; var dielModel = Math.floor(Math.random() * NUMBERS) + 1; var userWon = dielUser > dielModel; var bgColor = '#fff'; var fgColor = 'red'; if (userWon) { fgColor = 'green'; } cb.sendNotice(tip['from_user'] + ' got ' + dielUser + ' and model ' + dielModel, '', '#fff', 'red', 'bold'); if (userWon) { var rand = Math.floor(Math.random() * 3) + 1; var msg = tip['from_user'] + ' won ' + cb.settings['prize_' + rand]; cb.sendNotice(msg, '', '#C8E6C9', '#000', 'bold'); } } }); function advertise() { showAppAd(); cb.setTimeout(advertise, 5000); } function showAppAd(username) { var msg = ""; msg += "Running Tip Flood app"; cb.sendNotice(msg, username, '', '#15A6B0', 'bold'); } cb.onMessage(function(msg) { if (msg['m'].match(/!flood/)) { msg['X-Spam'] = true; } }); function init() { advertise(); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.