Apps Home
|
Create an App
John 3:17
Author:
blarfdotcom
Description
Source Code
Launch App
Current Users
Created by:
Blarfdotcom
const userLoyalty = new Map(); const optionsPrice = [ {name: 'Spanks', price: 5}, {name: 'Flash', price: 10}, {name: 'test', price: 15}, {name: 'test3', price: 20} ]; cb.onEnter(function(user) { cb.sendNotice('This room is using WhoreNickels Loyalty Points, you can earn fabulous rewards just for watching! Loyalty points accrue at 1 point per minute', user['user'], '#d135fc', '#ffffff', 'bold'); let optionsString = 'Current Loyalty Rewards are:\n'; for(let i = 0; i < optionsPrice.length; i++) { optionsString += optionsPrice[i].name + ' *' + optionsPrice[i].price + ' points* \n'; } cb.sendNotice(optionsString, user['user'], '#d135fc', '#ffffff', 'bold'); //Set loyalty for new users to the room if(!userLoyalty.has(user['user'])) { userLoyalty.set(user['user'], 0); } }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_11_21_31', 'row1_value': 'Your Loyalty Points:', 'row2_value': userLoyalty.get(user['user']), 'row3_value': '' }; }); cb.onMessage(function (msg) { msg['m'] = '[' + userLoyalty.get(msg['user']) + ' loyalty] ' + msg['m'] ; return msg; }); cb.tipOptions(function(user) { let loyaltyPoints = userLoyalty.get(user); let options = { options: [], label: "Redeem Loyalty Points:" } for(let i = 0; i < optionsPrice.length; i++){ if(optionsPrice[i].price <= loyaltyPoints){ //Display option by adding it to options array options.options.push({label: optionsPrice[i].name}); } } return options; }); cb.onTip(function (tip) { if(tip['message'].length > 0){ for(let i = 0; i < optionsPrice.length; i++){ if(tip['message'] === optionsPrice[i].name){ //Found tip, deduct from loyalty points and announce userLoyalty.set(tip['from_user'], userLoyalty.get(tip['from_user']) - optionsPrice[i].price); cb.sendNotice(tip['from_user'] + ' has cashed in ' + optionsPrice[i].price + ' loyalty points for ' + optionsPrice[i].name + '!'); } } cb.drawPanel(); } }); function giveLoyalty() { userLoyalty.forEach(function(value, key) { var newLoyalty = value + 1; userLoyalty.set(key, newLoyalty); cb.sendNotice("Loyalty Earned! You now have " + newLoyalty + " loyalty points!", key, '#d135fc', '#ffffff', 'bold'); }); cb.drawPanel(); cb.setTimeout(giveLoyalty, 60000); } cb.setTimeout(giveLoyalty, 60000);
© Copyright Chaturbate 2011- 2025. All Rights Reserved.