Apps Home
|
Create an App
Ryan's Gameshow Runner
Author:
warppipe
Description
Source Code
Launch App
Current Users
Created by:
Warppipe
var scores = {} //scores, with the player uernames as keys var answers = {} //answers, with their sources as keys var answerusers = [] //an array of who answered, alphabetically, for the purposes of keeping score var scoringusers = [] //an array of who gets points var scoreboardusers = [] var scoreboard = [] cb.onMessage(function(msg){ // clear variables and start timer if (msg['m'] == '/t' && msg['user'] == cb.room_slug){ cb.sendNotice('Timer started!'); cb.setTimeout(post_answers, 10000); msg['X-Spam'] = true; answers = {}; }; // collect an answer if (msg['m'].startsWith('/a')){ msg['X-Spam'] = true; answers[msg['user']] = msg['m'].substring(2); cb.sendNotice("Thank you for your answer!", msg['user']); }; // score answers if (msg['m'].startsWith('/score')){ msg['X-Spam'] = true; scoringusers.length = 0; scoringusers = msg['m'].substring(7).split(' '); var i; for (i = 0; i < scoringusers.length; i++){ if (scores[answerusers[scoringusers[i]]] == 0 || scores[answerusers[scoringusers[i]]] == '' || scores[answerusers[scoringusers[i]]] == null) { scores[answerusers[scoringusers[i]]] = 1; } else { scores[answerusers[scoringusers[i]]]++ }; }; post_scores(); }; }) function post_answers() { cb.sendNotice("Time's Up!"); answerusers = Object.keys(answers); var i; for (i = 0; i < answerusers.length; i++){ cb.sendNotice(answerusers[i] + '(' + i + ') says: ' + answers[answerusers[i]]); }; } function post_scores() { scoreboardusers = Object.keys(scores); scoreboard = [] scoreboard[0] = [scoreboardusers[0], scores[scoreboardusers[0]]] var i; for (i = 1; i < scoreboardusers.length; i++){ var j; for (j = 0; i < (scoreboard.length + 1); i++){ //don't insert yet it the value is greater if (scoreboard[j][1] > scores[scoreboardusers[i]]){continue;} scoreboard.splice(j, 0, [scoreboardusers[i], scores[scoreboardusers[i]]]); break; }; }; }
© Copyright Chaturbate 2011- 2025. All Rights Reserved.