Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name CAW CAW FLAG LIGHTS
- // @include http://*.koalabeast.com:*
- // @include http://*.jukejuice.com:*
- // @include http://*.newcompte.fr:*
- // @version 0.2
- // ==/UserScript==
- /*
- * CAW CAW Flag Lights by ??
- * Edited by ScHoolball Q
- * Colors adjusted by ----)
- */
- var game = 0;
- red = 0,
- blue = 0,
- flags = {},
- oldCSS = "",
- css = "",
- flagHeld = 0,
- lastFlagHeld = 0;
- var blueCSS = {background: "linear-gradient(90deg, rgba(0,0,0,1), rgba(0,0,200,1))"};
- var redCSS = {background: "linear-gradient(90deg, rgba(200,0,0,1), rgba(0,0,0,1))"};
- var redBlueCSS = {background: "linear-gradient(90deg, rgba(200,0,0,1), rgba(0,0,200,1))"};
- var greyCSS = {background: "linear-gradient(90deg, rgba(0,0,0,1), rgba(0,0,0,1))"};
- var yellowRedCSS = {background: "linear-gradient(90deg, rgba(255,255,0,1), rgba(0,0,0,1))"};
- var yellowBlueCSS = {background: "linear-gradient(90deg, rgba(0,0,0,1), rgba(255,255,0,1))"};
- var yellowRedBlueCSS = {background: "linear-gradient(90deg, rgba(255,255,0,1), rgba(255,255,0,1))"};
- init();
- function init() {
- // default values
- $("html").css("background-color", "rgba(0,0,0,0.25)");
- $("html").css(greyCSS);
- if (!tagpro.map) return setTimeout(function(){init();},0);
- checkPlayers();
- tagpro.socket.on("p", function(message) {
- if(!Array.isArray(message)) message = [message];
- for (var i = 0; i < message.length; i++) {
- var data = message[i].u;
- if(data !== undefined) {
- if (tagpro)
- for(var j = 0; j < data.length; j++) {
- if(data[j].flag || typeof data[j].flag == "object") { // a flag exists
- flagHeld = 1;
- checkPlayers();
- }
- }
- }
- }
- if(!flagHeld && lastFlagHeld) {setColor(0,0,0); flagHeld = 0;} // what type of game doesn't matter
- lastFlagHeld = flagHeld;
- });
- }
- function checkPlayers() {
- var oldgame = game, oldred = red, oldblue = blue;
- game = 1, red = 0, blue = 0; // assume CTF game
- for (var id in tagpro.players) {
- var player = tagpro.players[id];
- /*
- * FYI:
- *
- * player.flag == null, no flag (CTF && NF)
- * player.flag == 1, red flag (CTF)
- * player.flag == 2, blue flag (CTF)
- * player.flag == 3, yellow flag (NF)
- *
- * player.team == 1, red team
- * player.team == 2, blue team
- */
- switch (player.flag) {
- case 3: // NF Games
- game = 0;
- case 2: // CTF Games
- case 1:
- if (player.team == 1) red = 1;
- else if (player.team == 2) blue = 1;
- }
- }
- if (oldgame !== game || oldred !== red || oldblue !== blue) {
- setColor(game, red, blue);
- }
- }
- function setColor (game, red, blue) {
- css = greyCSS; // by default
- if (game === 0) { // NF Games
- if (red && blue) css = yellowRedBlueCSS;
- else if (red) css = redCSS;
- else if (blue) css = blueCSS;
- } else if (game === 1) { // CTF Games
- if (red && blue) css = redBlueCSS;
- else if (red) css = redCSS;
- else if (blue) css = blueCSS;
- }
- if (css != oldCSS) {
- $("html").css(css);
- oldCSS = css;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment