/***************************************************/ /* Made by Foly (and 2 lines by Artem)j */ /* Feel free to use/copy any part of this script */ /***************************************************/ //Variables array ColorArray(32, 365); enum Colors { //Colors in Top Secret Grey = 360, Red = 361, Yellow = 362, Green = 363, Cyan = 364, Purple = 365, LightGreen = 367, Black = 370, White = 371, Orange = 372, Blue = 480, DarkBlue = 499 } //Script only functions void ChangeTiles(int x1, int y1, int x2, int y2, int Tile) { //This function changes tiles in a square area with left top corner //(x1, y1) and right bottom corner (x2, y2) to Tile (number of the tile). for (int i = x1 - 1; i < x2; i++) { for (int j = y1 - 1; j < y2; j++) { if (!(jjTileGet(4, i, j) == 20)) jjTileSet(4, i, j, Tile); } } } bool PlayerInArea(int x1, int y1, int x2, int y2, int playerID) { //Checks if a player is in a square area with left top corner //(x1, y1) and right bottom corner (x2, y2). bool InArea; if ((jjPlayers[playerID].xPos > (x1*32 - 32)) && (jjPlayers[playerID].xPos < x2*32) && (jjPlayers[playerID].yPos > (y1*32 - 32)) && (jjPlayers[playerID].yPos < y2*32)) InArea = true; else InArea = false; return InArea; } void CheckColor(int pID) { if (PlayerInArea(26, 37, 26, 37, pID)) ColorArray[pID] = Red; if (PlayerInArea(30, 38, 30, 38, pID)) ColorArray[pID] = Purple; if (PlayerInArea(34, 39, 34, 39, pID)) ColorArray[pID] = Yellow; if (PlayerInArea(38, 40, 38, 40, pID)) ColorArray[pID] = Blue; if (PlayerInArea(42, 40, 42, 40, pID)) ColorArray[pID] = White; if (PlayerInArea(47, 39, 47, 39, pID)) ColorArray[pID] = Black; if (PlayerInArea(51, 38, 51, 38, pID)) ColorArray[pID] = Green; } void ClearAll() { ChangeTiles(24, 21, 53, 41, Black); ChangeTiles(37, 34, 40, 34, 20); ChangeTiles(30, 29, 33, 29, 20); } //Gameplay functions void onLevelLoad() { ClearAll(); } void onMain() { if ((jjGameTicks % 4) == 0) { //For lag reducing int a = jjPlayerCount + 1; //When there aren't many players don't go through all 32 player slots. for (int i = 0; i < 32; i++) { if (jjPlayers[i].isActive && (PlayerInArea(24, 21, 52, 40, i))) { //Look if the player is active and if it's in the painting area. a--; CheckColor(i); if (PlayerInArea(53, 37, 53, 37, i)) ClearAll(); if (jjTileGet(4, jjPlayers[i].xPos/32, jjPlayers[i].yPos/32) == 20) continue; jjTileSet(4, jjPlayers[i].xPos/32, jjPlayers[i].yPos/32, ColorArray[i]); //Change the tile at player i's position to player i's color. if (a == 0) break; //If all connected players are done stop the for loop. } } } }