Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.71 KB | None | 0 0
  1. // .all and .others
  2. // regex for spaces
  3. // vanish
  4. // join team
  5.  
  6. const SUPER_ADMIN = [127118, 127121, 127096, 127092, 2760, 4561] // Commands like kick, mute, unmute, etc.
  7. // integral, cosine, wumbo, philly
  8.  
  9. const request = require('request')
  10. const DONATORS = [] // 127118, 58
  11. const BANNED = [104394, 128855]
  12.  
  13. const PLAYER_DATA = [];
  14.  
  15. const SPEED_CAP = 100 // Fastest you can go without being unable to walk
  16. const JUMP_CAP = 50 // Highest you can go without spending a while in the air
  17. const SCALE_HIGH_CAP = 5 // Biggest you can get (limited for lag purposes)
  18. const SCALE_LOW_CAP = 0.1 // The lowest scale you can get. < 0 makes you become invisible
  19. const ALLOWED_KILLS = 5 // Amount of kills before said player gets kicked
  20.  
  21. const ADMIN_BLOCK = Game.findBrickByName("adminblock")
  22.  
  23. const DISCO_COLORS = [
  24. red = "#FF0000",
  25. orange = "#eb8034",
  26. yellow = "#fff200",
  27. green = "#00ff04",
  28. light_blue = "#00ffee",
  29. blue = "#0000FF",
  30. purple = "#7700ff",
  31. pink = "#ff00bb"
  32. ]
  33. let active = true; // debounce for disco
  34.  
  35. const COLORS = [
  36. blue = "#0066ff",
  37. red = "#ff0000",
  38. yellow = "#ffff00",
  39. purple = "#6f00ff",
  40. pink = "#ff00d0",
  41. orange = "#ff8800",
  42. green = "#22ff00"
  43. ] // Colors for team purposes
  44.  
  45. const HELP_DIALOG = {
  46. DONOR: {
  47. ambient: "/ambient (num); Changes the ambient color of the game",
  48. sky: "/sky (num); Changes the sky color of the game",
  49. freeze: "/freeze (player); Freezes said player",
  50. thaw: "/thaw (player); Thaws said player (if frozen)"
  51. },
  52. REG: {
  53. kill: "/kill (player); Kills player",
  54. tp: "/tp (player); Teleports you to said player",
  55. jump: "/jump (number); How high you can jump",
  56. speed: "/speed (number); How fast you can go",
  57. scale: "/scale (number); Changes the size of your character",
  58. av: "/av (id); Changes you to a different player via their ID",
  59. id: "/id (player); Gives you said player's ID",
  60. team: "/team (name); Makes a new team with a custom name",
  61. disco: "/disco; Changes the ambient color in rainbow order [epilepsy warning]"
  62. }
  63.  
  64. }
  65.  
  66.  
  67. let adminIds = new Set() // Admins first to join. Players who touch brick will be added here.
  68.  
  69.  
  70.  
  71. ADMIN_BLOCK.touching((plr) => {
  72. if (adminIds.has(plr.userId)) return
  73. if (!plr.alive) return
  74. adminIds.add(plr.userId)
  75. console.log(`[----------------------${plr.username} just became an admin----------------------]`)
  76. plr.centerPrint("You became an admin! Type [#FF0000]/cmds[#FF0000] for valid commands", 7)
  77. change("You became an admin! Type [#FF0000]/cmds[#FFFFFF] for valid commands", null, plr);
  78. })
  79.  
  80.  
  81.  
  82. function change(msg, val, plr) { // Messaging function
  83. if (!val) val = ""
  84. const serverMsg = `\\h09ff00[CHANGE]: \\hffffff${msg} ${val}`
  85. plr.message(serverMsg);
  86. }
  87.  
  88. function isAdmin(userId) { // Checking if an admin
  89. return adminIds.has(userId);
  90. }
  91.  
  92. function isSuperAdmin(userId) { // Checking if a super admin
  93. return SUPER_ADMIN.includes(userId);
  94. }
  95.  
  96. function isDonator(userId) {
  97. return DONATORS.includes(userId);
  98. }
  99.  
  100. function isBanned(userId) {
  101. return BANNED.includes(userId);
  102. }
  103.  
  104. function getPlayer(name) {
  105. const username = name.toLowerCase()
  106. if (name)
  107. if (username == ".all") { // Getting all players
  108. for (let player of Game.players) {
  109. const victim = Game.findPlayerByUsername(player.username)
  110. return victim
  111. }
  112. } else {
  113. for (let player of Game.players) { // Gets specific player
  114. if (player.username.toLowerCase().indexOf(username) == 0) {
  115. const victim = Game.findPlayerByUsername(player.username)
  116. return victim
  117. }
  118. }
  119. }
  120. }
  121.  
  122. Game.on('speedCmd', (plr, msg) => {
  123. if (!isAdmin(plr.userId)) return
  124. if (isNaN(msg)) return
  125. if (Number(msg) > SPEED_CAP) {
  126. plr.speed = SPEED_CAP;
  127. } else {
  128. plr.speed = Number(msg)
  129. }
  130. change("you changed your speed to", plr.speed, plr)
  131. })
  132.  
  133.  
  134. Game.on('killCmd', (plr, msg) => {
  135. if (!isAdmin(plr.userId)) return
  136. if (plr.score >= ALLOWED_KILLS - 1) {
  137. return plr.kick("you killed too many players");
  138. }
  139. const victim = getPlayer(msg)
  140. if (victim) {
  141. victim.respawn()
  142. plr.score++
  143. plr.message(`[#ffa500][WARN]:[#FFFFFF] if you kill ${ALLOWED_KILLS - plr.score} more players, you WILL BE kicked`)
  144. Game.messageAll(`[#FF0000][ALERT]: [#FFFFFF]${victim.username} has been killed by ${plr.username}`)
  145. }
  146. })
  147.  
  148. Game.on('jumpCmd', (plr, msg) => {
  149. if (!isAdmin(plr.userId)) return
  150. if (isNaN(msg)) return
  151. if (msg > JUMP_CAP)
  152. plr.jumpPower = JUMP_CAP
  153. else
  154. plr.jumpPower = msg
  155. change("you changed your jump height to", plr.jumpPower, plr)
  156. })
  157.  
  158. Game.on('plrCmd', () => {
  159. console.log(Game.players)
  160. })
  161.  
  162. Game.on('tpCmd', (plr, msg) => {
  163. if (!isAdmin(plr.userId)) return
  164. let player = getPlayer(msg)
  165. if (player) {
  166. plr.position = player.position
  167. }
  168. })
  169.  
  170.  
  171.  
  172. Game.on('teamCmd', (plr, msg) => {
  173. if (!isAdmin(plr.userId)) return
  174. const randomColor = COLORS[Math.floor(Math.random() * COLORS.length)]
  175. const team = new Team(msg, randomColor)
  176. plr.team = team
  177. Game.messageAll(`[#00eeff][TEAM]: [#FFFFFF]${plr.username} created [#00eeff]${team.name}`)
  178. console.log(`${plr.username} created ${team.name}`)
  179. })
  180.  
  181.  
  182. // Could be improved
  183. Game.on('scaleCmd', (plr, msg) => {
  184. if (!isAdmin(plr.userId)) return
  185. if (isNaN(msg)) return
  186. if (Number(msg) > SCALE_HIGH_CAP) {
  187. plr.scale = {
  188. x: SCALE_HIGH_CAP,
  189. y: SCALE_HIGH_CAP,
  190. z: SCALE_HIGH_CAP
  191. }
  192. change(`you set your scale to (${SCALE_HIGH_CAP}, ${SCALE_HIGH_CAP}, ${SCALE_HIGH_CAP})`, null, plr)
  193. } else if (Number(msg) <= 0.1) {
  194. plr.scale = {
  195. x: SCALE_LOW_CAP,
  196. y: SCALE_LOW_CAP,
  197. z: SCALE_LOW_CAP
  198. };
  199. change(`you set your scale to (${SCALE_LOW_CAP}, ${SCALE_LOW_CAP}, ${SCALE_LOW_CAP})`, null, plr)
  200. } else {
  201. plr.scale = {
  202. x: msg,
  203. y: msg,
  204. z: msg
  205. }
  206. change(`you set your scale to (${msg}, ${msg}, ${msg})`, null, plr)
  207. }
  208. })
  209.  
  210.  
  211. Game.on('idCmd', (plr, msg) => {
  212. if (!isAdmin(plr.userId)) return
  213. let player = getPlayer(msg);
  214. if (player) {
  215. plr.message(`[#ffa500][REQUEST]: [#FFFFFF]${player.username}'s id is [#ffa500]${player.userId}`);
  216. }
  217. })
  218.  
  219. Game.on('cmdsCmd', (plr) => {
  220. if (!isAdmin(plr.userId)) return
  221. Object.keys(HELP_DIALOG.REG).map((key) => {
  222. plr.message(`[#ffa500][REQUEST]: \\hffffff${HELP_DIALOG.REG[key]}`)
  223. })
  224. })
  225.  
  226. Game.on('discoCmd', (plr) => {
  227. if (!isAdmin(plr.userId)) return
  228. if (!active) return
  229. let index = 0;
  230.  
  231. Game.centerPrintAll(`[#FF0000][WARNING]: [#FFFFFF]disco was initated and contains flashing colors!`, 3)
  232. setTimeout(() => { // waiting for warning
  233.  
  234. discoActive = setInterval(() => {
  235.  
  236. active = false
  237. for (let players of Game.players) {
  238.  
  239. try {
  240.  
  241. players.setEnvironment({
  242. ambient: DISCO_COLORS[index++ % DISCO_COLORS.length]
  243. })
  244.  
  245. } catch {}
  246. }
  247.  
  248. }, 1000); // interval between each color
  249.  
  250. }, 3000); // how long the warning is
  251. setTimeout(() => {
  252.  
  253. clearInterval(discoActive)
  254. for (let players of Game.players) {
  255.  
  256. try {
  257.  
  258. players.setEnvironment({
  259. ambient: 1
  260. })
  261. active = true;
  262. index = 0; // reset the index
  263. } catch {}
  264. }
  265. }, DISCO_COLORS.length * 2000); // how many times you should do it --> doing it twice
  266. })
  267.  
  268.  
  269. // ------------------------------------ Super Admin commands ------------------------------------ \\
  270.  
  271. Game.on('configCmd', (plr) => {
  272. if (!isSuperAdmin(plr.userId)) return
  273. plr.speed = 10
  274. plr.jumpPower = 10
  275. plr.scale = {
  276. x: 1.5,
  277. y: 1.5,
  278. z: 1.5
  279. }
  280. })
  281.  
  282. Game.on('kickCmd', (plr, msg) => {
  283. if (!isSuperAdmin(plr.userId)) return
  284. const victim = getPlayer(msg)
  285. if (victim) {
  286. victim.kick(`You were kicked by ${plr.username}`)
  287. Game.messageAll(`[#FF0000][ALERT]: ${victim.username}[#FFFFFF] was kicked by [#FF0000]${plr.username}`)
  288. console.log(`////////////////////////////////${victim.username} was kicked by ${plr.username}////////////////////////////////`)
  289. }
  290. })
  291.  
  292.  
  293.  
  294. Game.on('serverCmd', (plr, msg) => {
  295. if (!isSuperAdmin(plr.userId)) return
  296. Game.messageAll(`[#FF0000][SERVER]: [#FFFFFF]${msg}`)
  297. })
  298.  
  299. // Toggle mute, it's cleaner
  300. Game.on('muteCmd', (plr, msg) => {
  301. if (!isSuperAdmin(plr.userId)) return
  302. const player = getPlayer(msg)
  303. if (player) {
  304. player.muted = !player.muted
  305. if (player.muted) {
  306. change("You have been muted!", null, player)
  307. } else change("You have been unmuted!", null, player)
  308. }
  309. })
  310.  
  311. Game.on('isadminCmd', (plr, msg) => {
  312. if (!isSuperAdmin(plr.userId)) return
  313. const player = getPlayer(msg)
  314. if (player) {
  315. if (isAdmin(player.userId))
  316. plr.message(`[#ffa500][REQUEST]: [#FFFFFF]${player.username} is an admin`)
  317. else
  318. plr.message(`[#ffa500][REQUEST]: [#FFFFFF]${player.username} is NOT an admin`)
  319. }
  320. })
  321.  
  322. Game.on('tpmeCmd', (plr, msg) => {
  323. if (!isSuperAdmin(plr.userId)) return
  324. const victim = getPlayer(msg)
  325. if (victim) {
  326. victim.position = plr.position
  327. }
  328. })
  329.  
  330. Game.on('statsCmd', (plr, msg) => {
  331. if (!isSuperAdmin(plr.userId)) return
  332. const victim = getPlayer(msg)
  333. if (victim) {
  334. for (let data of PLAYER_DATA) {
  335. if (data.id === victim.userId) {
  336. console.log(data)
  337. }
  338. }
  339. }
  340. })
  341.  
  342. Game.on('adminCmd', (plr, msg) => {
  343. if (!isSuperAdmin(plr.userId)) return;
  344. const victim = getPlayer(msg);
  345. if (victim) {
  346. if (isAdmin(victim.userId)) {
  347. adminIds.delete(victim.userId);
  348. victim.centerPrint(`[#ffa500]Your admin has been taken away by [#FF0000]${plr.username}`, 5)
  349. change(`Your admin has been taken away by [#FF0000]`, plr.username, victim);
  350. } else {
  351. adminIds.add(victim.userId);
  352. victim.centerPrint(`[#ffa500]you became an admin! Check the desc of the game for valid commands`, 5)
  353. change("you became an admin! Check the desc of the game for valid commands", null, victim);
  354. }
  355. }
  356. })
  357.  
  358. Game.on('vCmd', (plr, msg) => {
  359. if (!isSuperAdmin(plr.userId)) return
  360. const team = new Team(" ", "#ffffff") // make platform
  361. })
  362.  
  363.  
  364. // ------------------------------------ Removing admin when player leaves ------------------------------------ \\
  365.  
  366. Game.on('playerLeave', (plr) => {
  367. if (isAdmin(plr.userId) && !isSuperAdmin(plr.userId)) {
  368. adminIds.delete(plr.userId)
  369. }
  370. })
  371.  
  372. Game.on('avCmd', async (plr, msg) => {
  373. if (!isAdmin(plr.userId)) return
  374. if (isNaN(msg)) return
  375. await plr.setAvatar(msg).then(() => {
  376. change("you changed your id to", msg, plr)
  377. }).catch(() => {
  378. change("failure setting avatar id", null, plr)
  379. })
  380. })
  381.  
  382. Game.on('playerJoin', async (plr) => {
  383. if (isBanned(plr.userId)) {
  384. return plr.kick("You are banned from this server.")
  385. }
  386.  
  387. const PLR_DATA = {
  388. id: plr.userId,
  389. name: plr.username,
  390. superadmin: isSuperAdmin(plr.userId),
  391. frozen: false
  392. }
  393.  
  394. await request("https://api.brick-hill.com/v1/shop/owners?id=65663", async (err, res, data) => {
  395. const json = await JSON.parse(data);
  396. for (let index of json) {
  397. const id = await index.owner;
  398. if (id) {
  399. if (!DONATORS.includes(id)) {
  400. DONATORS.push(id)
  401. }
  402. }
  403. }
  404. })
  405.  
  406. PLAYER_DATA.push(PLR_DATA)
  407.  
  408. plr.centerPrint("Enter the house and step on the white brick for admin!", 7)
  409. })
  410.  
  411. // ------------------------------------ Donator commands ------------------------------------ \\
  412.  
  413. Game.on('ambientCmd', (plr, num) => {
  414. if (!isDonator(plr.userId)) return
  415. if (isNaN(num)) return
  416. for (let player of Game.players) { // Setting ambient for each player since it's local
  417. try {
  418. player.setEnvironment({
  419. ambient: Number(num)
  420. })
  421. console.log(num)
  422. } catch (err) {}
  423. }
  424. })
  425.  
  426. Game.on('skyCmd', (plr, num) => {
  427. if (!isDonator(plr.userId)) return
  428. if (isNaN(num)) return
  429. try {
  430. Game.setEnvironment({
  431. skyColor: Number(num)
  432. })
  433. } catch (err) {}
  434. })
  435.  
  436. Game.on('dcmdsCmd', (plr) => {
  437. if (!isDonator(plr.userId)) return
  438. Object.keys(HELP_DIALOG.DONOR).map((key) => {
  439. plr.message(`[#ffa500][REQUEST]: [#FFFFFF]${HELP_DIALOG.DONOR[key]}`)
  440. })
  441. })
  442.  
  443. Game.on('freezeCmd', (plr, msg) => {
  444. if (!isDonator(plr.userId)) return
  445. const victim = getPlayer(msg);
  446. if (victim) {
  447. victim.speed = 0;
  448. victim.jumpPower = 0;
  449. victim.centerPrint(`[#009dff][FROZEN]: [#FFFFFF]You have been frozen by [#009dff]${plr.username}`, 5)
  450. }
  451. }) // integral
  452.  
  453. Game.on('thawCmd', (plr, msg) => {
  454. if (!isDonator(plr.userId)) return
  455. const victim = getPlayer(msg);
  456. if (victim) {
  457. victim.speed = 4;
  458. victim.jumpPower = 5;
  459. victim.centerPrint(`[#009dff][THAWED]: [#FFFFFF]You have been thawed by [#009dff]${plr.username}`, 5)
  460. }
  461. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement