Advertisement
Guest User

Untitled

a guest
Feb 8th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.95 KB | None | 0 0
  1. var Logger = require('./Logger');
  2. var UserRoleEnum = require("../enum/UserRoleEnum");
  3.  
  4. function PlayerCommand(gameServer, playerTracker) {
  5. this.gameServer = gameServer;
  6. this.playerTracker = playerTracker;
  7. this.roleList = [];
  8. this.admins = [];
  9. }
  10. module.exports = PlayerCommand;
  11.  
  12. PlayerCommand.prototype.writeLine = function (text) {
  13. this.gameServer.sendChatMessage(null, this.playerTracker, text);
  14. };
  15.  
  16. PlayerCommand.prototype.executeCommandLine = function(commandLine) {
  17. if (!commandLine) return;
  18.  
  19. // Splits the string
  20. var args = commandLine.split(" ");
  21.  
  22. // Process the first string value
  23. var first = args[0].toLowerCase();
  24.  
  25. // Get command function
  26. var execute = playerCommands[first];
  27. if (typeof execute != 'undefined') {
  28. execute.bind(this)(args);
  29. } else {
  30. this.writeLine("ERROR: Unknown command, type /help for command list");
  31. }
  32. };
  33.  
  34.  
  35. PlayerCommand.prototype.userLogin = function (username, password) {
  36. if (!username || !password) return null;
  37. for (var i = 0; i < this.gameServer.userList.length; i++) {
  38. var user = this.gameServer.userList[i];
  39. if (user.username != username)
  40. break;
  41. if (user.password != password)
  42. break;
  43. return user;
  44. }
  45. return null;
  46. };
  47.  
  48. var playerCommands = {
  49. help: function (args) {
  50. var page = parseInt(args[1]);
  51. if (this.playerTracker.userRole == UserRoleEnum.ADMIN || this.playerTracker.userRole == UserRoleEnum.MODER) {
  52. if (isNaN(page)) {
  53. this.writeLine("Please Enter a Page Number!");
  54. return;
  55. }
  56. if (page == 1) {
  57. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  58. this.writeLine("/skin %shark - change skin");
  59. this.writeLine("/kill - self kill");
  60. this.writeLine("/help [page #] - this command list");
  61. this.writeLine("/id - Gets your playerID");
  62. this.writeLine("/mass - gives mass to yourself or to other players");
  63. this.writeLine("/merge - Instantly Recombines all of your cells or other players cells");
  64. this.writeLine("/rec - Toggles rec mode for you or for other players - MUST BE ADMIN");
  65. this.writeLine("/spawnmass - gives yourself or other players spawnmass - MUST BE ADMIN");
  66. this.writeLine("/minion - gives yourself or other players minions");
  67. this.writeLine("/minion remove - removes all of your minions or other players minions");
  68. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  69. this.writeLine("Showing Page 1 of 2.");
  70. } else if (page == 2) {
  71. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  72. this.writeLine("/userrole - Allows you to give User Role to a player ID - MUST BE ADMIN");
  73. this.writeLine("/userrole list - Lists all the people you have given a Role - MUST BE ADMIN");
  74. this.writeLine("/kick - Kicks a Player ID to make them lose their Temporarily Role");
  75. this.writeLine("/addbot - Adds Bots to the Server - MUST BE ADMIN");
  76. this.writeLine("/change - Allows you to Temporarily change the config of the Server! - MUST BE ADMIN");
  77. this.writeLine("/reloadconfig - Reloads the config of the Server to the gameServer.ini file - MUST BE ADMIN");
  78. this.writeLine("/shutdown - SHUTDOWNS THE SERVER - MUST BE ADMIN");
  79. this.writeLine("/restart - RESTARTS THE SERVER - MUST BE ADMIN");
  80. this.writeLine("/status - Shows Status of the Server");
  81. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  82. this.writeLine("Showing Page 2 of 2.");
  83. }
  84. }
  85. else {
  86. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  87. this.writeLine("/skin %shark - change skin");
  88. this.writeLine("/kill - self kill");
  89. this.writeLine("/help - this command list");
  90. this.writeLine("/id - Gets your playerID");
  91. this.writeLine("/list - Lists the players in-game");
  92. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  93. }
  94. },
  95. id: function (args) {
  96. this.writeLine("Your PlayerID is " + this.playerTracker.pID);
  97. },
  98. skin: function (args) {
  99. if (this.playerTracker.cells.length) {
  100. this.writeLine("ERROR: Cannot change skin while player in game!");
  101. return;
  102. }
  103. var skinName = "";
  104. if (args[1]) skinName = args[1];
  105. this.playerTracker.setSkin(skinName);
  106. if (skinName == "")
  107. this.writeLine("Your skin was removed");
  108. else
  109. this.writeLine("Your skin set to " + skinName);
  110. },
  111. kill: function (args) {
  112. if (!this.playerTracker.cells.length) {
  113. this.writeLine("You cannot kill yourself, because you're still not joined to the game!");
  114. return;
  115. }
  116. while (this.playerTracker.cells.length) {
  117. var cell = this.playerTracker.cells[0];
  118. this.gameServer.removeNode(cell);
  119. // replace with food
  120. var food = require('../entity/Food');
  121. food = new food(this.gameServer, null, cell.position, cell._size);
  122. food.setColor(cell.color);
  123. this.gameServer.addNode(food);
  124. }
  125. this.writeLine("You killed yourself");
  126. },
  127. list: function (args) {
  128. for (var i in this.admins) {
  129. this.writeLine(this.admins[i].username + " ~~~~ " + this.admins[i].name);
  130. }
  131. },
  132. mass: function (args) {
  133. if (this.playerTracker.userRole != UserRoleEnum.ADMIN && this.playerTracker.userRole != UserRoleEnum.MODER) {
  134. this.writeLine("ERROR: access denied!");
  135. return;
  136. }
  137. var mass = parseInt(args[1]);
  138. var id = parseInt(args[2]);
  139. var size = Math.sqrt(mass * 100);
  140.  
  141. if (isNaN(mass)) {
  142. this.writeLine("ERROR: missing mass argument!");
  143. return;
  144. }
  145.  
  146. if (isNaN(id)) {
  147. this.writeLine("Warn: missing ID arguments. This will change your mass.");
  148. for (var i in this.playerTracker.cells) {
  149. this.playerTracker.cells[i].setSize(size);
  150. }
  151. this.writeLine("Set mass of " + this.playerTracker._name + " to " + size * size / 100);
  152.  
  153. } else {
  154. for (var i in this.gameServer.clients) {
  155. var client = this.gameServer.clients[i].playerTracker;
  156. if (client.pID == id) {
  157. for (var j in client.cells) {
  158. client.cells[j].setSize(size);
  159. }
  160. this.writeLine("Set mass of " + client._name + " to " + size * size / 100);
  161. var text = this.playerTracker._name + " changed your mass to " + size * size / 100;
  162. this.gameServer.sendChatMessage(null, client, text);
  163. break;
  164. }
  165. }
  166. }
  167.  
  168. },
  169. spawnmass: function (args) {
  170. if (this.playerTracker.userRole != UserRoleEnum.ADMIN) {
  171. this.writeLine("ERROR: access denied!");
  172. return;
  173. }
  174. var mass = parseInt(args[1]);
  175. var id = parseInt(args[2]);
  176. var size = Math.sqrt(mass * 100);
  177.  
  178. if (isNaN(mass)) {
  179. this.writeLine("ERROR: missing mass argument!");
  180. return;
  181. }
  182.  
  183. if (isNaN(id)) {
  184. this.playerTracker.spawnmass = size;
  185. this.writeLine("Warn: missing ID arguments. This will change your spawnmass.");
  186. this.writeLine("Set spawnmass of " + this.playerTracker._name + " to " + size * size / 100);
  187. } else {
  188. for (var i in this.gameServer.clients) {
  189. var client = this.gameServer.clients[i].playerTracker;
  190. if (client.pID == id) {
  191. client.spawnmass = size;
  192. this.writeLine("Set spawnmass of " + client._name + " to " + size * size / 100);
  193. var text = this.playerTracker._name + " changed your spawn mass to " + size * size / 100;
  194. this.gameServer.sendChatMessage(null, client, text);
  195. }
  196. }
  197. }
  198. },
  199. minion: function(args) {
  200. if (this.playerTracker.userRole != UserRoleEnum.ADMIN && this.playerTracker.userRole != UserRoleEnum.MODER) {
  201. this.writeLine("ERROR: access denied!");
  202. return;
  203. }
  204. if (this.playerTracker.userRole == UserRoleEnum.ADMIN) {
  205. var add = args[1];
  206. var id = parseInt(args[2]);
  207. }
  208. var player = this.playerTracker;
  209. if (this.playerTracker.userRole == UserRoleEnum.MODER) {
  210. var add = args[1];
  211. }
  212. /** For you **/
  213. if (this.playerTracker.userRole == UserRoleEnum.ADMIN) {
  214. if (isNaN(id)) {
  215. this.writeLine("Warn: missing ID arguments. This will give you minions.");
  216. // Remove minions
  217. if (player.minionControl == true && add == "remove") {
  218. player.minionControl = false;
  219. player.miQ = 0;
  220. this.writeLine("Succesfully removed minions for " + player._name);
  221. // Add minions
  222. } else {
  223. player.minionControl = true;
  224. // Add minions for self
  225. if (isNaN(parseInt(add))) add = 1;
  226. for (var i = 0; i < add; i++) {
  227. this.gameServer.bots.addMinion(player);
  228. }
  229. this.writeLine("Added " + add + " minions for " + player._name);
  230. }
  231.  
  232. } else {
  233. /** For others **/
  234. for (var i in this.gameServer.clients) {
  235. var client = this.gameServer.clients[i].playerTracker;
  236. if (client.pID == id) {
  237. // Remove minions
  238. if (client.minionControl == true) {
  239. client.minionControl = false;
  240. client.miQ = 0;
  241. this.writeLine("Succesfully removed minions for " + client._name);
  242. var text = this.playerTracker._name + " removed all off your minions.";
  243. this.gameServer.sendChatMessage(null, client, text);
  244. // Add minions
  245. } else {
  246. client.minionControl = true;
  247. // Add minions for client
  248. if (isNaN(parseInt(add))) add = 1;
  249. for (var i = 0; i < add; i++) {
  250. this.gameServer.bots.addMinion(client);
  251. }
  252. this.writeLine("Added " + add + " minions for " + client._name);
  253. var text = this.playerTracker._name + " gave you " + add + " minions.";
  254. this.gameServer.sendChatMessage(null, client, text);
  255. }
  256. }
  257. }
  258. }
  259. } else {
  260. if (add = "remove" && player.minionControl == true) {
  261. player.minionControl = false;
  262. player.miQ = 0;
  263. this.writeLine("Successfully removed minions for " + player._name);
  264. } else {
  265. player.minionControl = true;
  266. if (player.miQ > 1) {
  267. this.writeLine("You can't have more then 1 minion!");
  268. return;
  269. } else
  270. { this.gameServer.bots.addMinion(player);
  271. this.writeLine("Gave " + player._name + " 1 minion");
  272. }
  273. }
  274.  
  275. }
  276. },
  277. userrole: function(args) {
  278. // Temporarily changes the User Role of a player until that player leaves the server.
  279. if (this.playerTracker.userRole != UserRoleEnum.ADMIN) {
  280. this.writeLine("ERROR: access denied");
  281. return;
  282. }
  283. var id = args[1];
  284. var role = args[2];
  285. if(isNaN(parseInt(id))) {
  286. this.writeLine("Please specify a valid player ID!");
  287. if (id == "list") {
  288. if (!this.roleList.length) {
  289. this.writeLine("You have not given anyone a Role!");
  290. return;
  291. }
  292. this.writeLine(" ID | SCORE | NICK");
  293. for (var i in this.roleList) {
  294. var client = this.roleList[i];
  295. var id = client.pID;
  296. var nick = client._name;
  297. var score = Math.round(client._score);
  298. this.writeLine(id + " " + score + " " + nick);
  299. }
  300. return;
  301. }
  302. return;
  303. } else {
  304. if (role != "moder" && role != "user" && role != "guest" || role == null) {
  305. this.writeLine("Please specify a valid Role!");
  306. return;
  307. }
  308. if (this.playerTracker.pID == id) {
  309. this.writeLine("You cannot change your own Role!");
  310. return;
  311. }
  312. for (var i in this.gameServer.clients) {
  313. var client = this.gameServer.clients[i].playerTracker;
  314. if (client.pID == id) {
  315. if (client.userRole == UserRoleEnum.ADMIN) {
  316. this.writeLine("You cannot change Admins Roles!");
  317. return;
  318. }
  319. if (role == "moder") {
  320. client.userRole = UserRoleEnum.MODER;
  321. this.writeLine("Successfully changed " + client._name + "'s Role to Moder");
  322. this.gameServer.sendChatMessage(null, client, "You have been temporarily changed to MODER."); // notify
  323. this.roleList.push(client);
  324. } else if (role == "user") {
  325. client.userRole = UserRoleEnum.USER;
  326. this.writeLine("Successfully changed " + client._name + "'s Role to User!");
  327. this.gameServer.sendChatMessage(null, client, "You have been temporarily changed to USER."); // notify
  328. this.roleList.push(client);
  329. } else {
  330. client.userRole = UserRoleEnum.GUEST;
  331. this.writeLine("Successfully changed " + client._name + "'s Role to Guest!");
  332. this.gameServer.sendChatMessage(null, client, "You have been temporarily changed to GUEST."); // notify
  333. this.roleList.push(client);
  334. }
  335. }
  336. }
  337. }
  338. },
  339. kick: function(args) {
  340. var id = parseInt(args[1]);
  341. if (this.playerTracker.userRole != UserRoleEnum.ADMIN && this.playerTracker.userRole != UserRoleEnum.MODER) {
  342. this.writeLine("ERROR: acces denied!");
  343. return;
  344. }
  345. if (isNaN(id)) {
  346. this.writeLine("Please specify a valid player ID!");
  347. return;
  348. }
  349. // kick player
  350. var count = 0;
  351. this.gameServer.clients.forEach(function (socket) {
  352. if (socket.isConnected === false)
  353. return;
  354. if (id !== 0 && socket.playerTracker.pID != id)
  355. return;
  356. if (socket.playerTracker.userRole == UserRoleEnum.ADMIN) {
  357. this.writeLine("You cannot kick a ADMIN in game!");
  358. return;
  359. }
  360. // remove player cells
  361. for (var j = 0; j < socket.playerTracker.cells.length; j++) {
  362. this.gameServer.removeNode(socket.playerTracker.cells[0]);
  363. count++;
  364. }
  365. // disconnect
  366. socket.close(1000, "Kicked from server");
  367. var name = socket.playerTracker._name;
  368. this.writeLine("Successfully kicked " + name);
  369. count++;
  370. }, this);
  371. if (count) return;
  372. if (!id) this.writeLine("Warn: No players to kick!");
  373. else this.writeLine("Warn: Player with ID " + id + " not found!");
  374. },
  375. addbot: function(args) {
  376. var add = parseInt(args[1]);
  377. if (isNaN(add)) add = 1;
  378. if (this.playerTracker.userRole != UserRoleEnum.ADMIN) {
  379. this.writeLine("ERROR: access denied!");
  380. return;
  381. }
  382. for (var i = 0; i < add; i++) {
  383. this.gameServer.bots.addBot();
  384. }
  385. Logger.warn(this.playerTracker.socket.remoteAddress + " ADDED " + add + " BOTS");
  386. this.writeLine("Added " + add + " Bots");
  387. },
  388. status: function(args) {
  389. if (this.playerTracker.userRole != UserRoleEnum.ADMIN && this.playerTracker.userRole != UserRoleEnum.MODER) {
  390. this.writeLine("ERROR: access denied!");
  391. return;
  392. }
  393. // Get amount of humans/bots
  394. var humans = 0,
  395. bots = 0;
  396. for (var i = 0; i < this.gameServer.clients.length; i++) {
  397. if ('_socket' in this.gameServer.clients[i]) {
  398. humans++;
  399. } else {
  400. bots++;
  401. }
  402. }
  403. var ini = require('./ini.js');
  404. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  405. this.writeLine("Connected players: " + this.gameServer.clients.length + "/" + this.gameServer.config.serverMaxConnections);
  406. this.writeLine("Players: " + humans + " - Bots: " + bots);
  407. this.writeLine("Server has been running for " + Math.floor(process.uptime() / 60) + " minutes");
  408. this.writeLine("Current memory usage: " + Math.round(process.memoryUsage().heapUsed / 1048576 * 10) / 10 + "/" + Math.round(process.memoryUsage().heapTotal / 1048576 * 10) / 10 + " mb");
  409. this.writeLine("Current game mode: " + this.gameServer.gameMode.name);
  410. this.writeLine("Current update time: " + this.gameServer.updateTimeAvg.toFixed(3) + " [ms] (" + ini.getLagMessage(this.gameServer.updateTimeAvg) + ")");
  411. this.writeLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  412. },
  413. merge: function(args) {
  414. // Validation checks
  415. if (this.playerTracker.userRole != UserRoleEnum.ADMIN && this.playerTracker.userRole != UserRoleEnum.MODER) {
  416. this.writeLine("ERROR: access denied!");
  417. return;
  418. }
  419. var id = parseInt(args[1]);
  420. if (isNaN(id)) {
  421. this.writeLine("Warn: Missing ID arguments. This will merge you.");
  422. if (this.playerTracker.cells.length == 1) {
  423. this.writeLine("You already have one cell!");
  424. return;
  425. }
  426. this.playerTracker.mergeOverride = !this.playerTracker.mergeOverride;
  427. if (this.playerTracker.mergeOverride) this.writeLine(this.playerTracker._name + " is now force mergeing");
  428. else this.writeLine(this.playerTracker._name + " isn't force merging anymore");
  429. } else {
  430.  
  431. // Find client with same ID as player entered
  432. for (var i = 0; i < this.gameServer.clients.length; i++) {
  433. if (id == this.gameServer.clients[i].playerTracker.pID) {
  434. var client = this.gameServer.clients[i].playerTracker;
  435. if (client.cells.length == 1) {
  436. this.writeLine("Client already has one cell!");
  437. return;
  438. }
  439. // Set client's merge override
  440. client.mergeOverride = !client.mergeOverride;
  441. if (client.mergeOverride) {
  442. this.writeLine(client._name + " is now force merging");
  443. var text = this.playerTracker._name + " Caused you to merge!";
  444. this.gameServer.sendChatMessage(null, client, text); // notify
  445. }
  446. else {
  447. this.writeLine(client._name + " isn't force merging anymore");
  448. var text = this.playerTracker._name + " Stopped your mergeing"
  449. this.gameServer.sendChatMessage(null, client, text); // notify
  450. }
  451. }
  452. }
  453. }
  454. },
  455. rec: function(args) {
  456. var id = parseInt(args[1]);
  457. if (isNaN(id)) {
  458. this.writeLine("Warn: Missing ID arguments. This will give you rec mode.");
  459. this.playerTracker.rec = !this.playerTracker.rec;
  460. if (this.playerTracker.rec) this.writeLine(this.playerTracker._name + " is now in rec mode!");
  461. else this.writeLine(this.playerTracker._name + " is no longer in rec mode");
  462. }
  463.  
  464. // set rec for client
  465. for (var i in this.gameServer.clients) {
  466. if (this.gameServer.clients[i].playerTracker.pID == id) {
  467. var client = this.gameServer.clients[i].playerTracker;
  468. client.rec = !client.rec;
  469. if (client.rec) {
  470. this.writeLine(client._name + " is now in rec mode!");
  471. var text = this.playerTracker._name + " gave you rec mode!";
  472. this.gameServer.sendChatMessage(null, client, text); // notify
  473. } else {
  474. this.writeLine(client._name + " is no longer in rec mode");
  475. var text = this.playerTracker._name + " Removed your rec mode";
  476. this.gameServer.sendChatMessage(null, client, text); // notify
  477. }
  478. }
  479. }
  480. },
  481. change: function(args) {
  482. if (this.playerTracker.userRole != UserRoleEnum.ADMIN) {
  483. this.writeLine("ERROR: access denied!");
  484. return;
  485. }
  486. if (args.length < 3) {
  487. this.writeLine("Invalid command arguments");
  488. return;
  489. }
  490. var key = args[1];
  491. var value = args[2];
  492.  
  493. // Check if int/float
  494. if (value.indexOf('.') != -1) {
  495. value = parseFloat(value);
  496. } else {
  497. value = parseInt(value);
  498. }
  499.  
  500. if (value == null || isNaN(value)) {
  501. this.writeLine("Invalid value: " + value);
  502. return;
  503. }
  504. if (!this.gameServer.config.hasOwnProperty(key)) {
  505. this.writeLine("Unknown config value: " + key);
  506. return;
  507. }
  508. this.gameServer.config[key] = value;
  509.  
  510. // update/validate
  511. this.gameServer.config.playerMinSize = Math.max(32, this.gameServer.config.playerMinSize);
  512. Logger.setVerbosity(this.gameServer.config.logVerbosity);
  513. Logger.setFileVerbosity(this.gameServer.config.logFileVerbosity);
  514. this.writeLine("Set " + key + " = " + this.gameServer.config[key]);
  515. Logger.warn("CONFIGURATION CHANGE REQUEST FROM " + this.playerTracker.socket.remoteAddress + " as " + this.playerTracker.userAuth);
  516. Logger.info(key + " WAS CHANGED TO " + value);
  517. },
  518. reloadconfig: function(args) {
  519. if (this.playerTracker.userRole != UserRoleEnum.ADMIN) {
  520. this.writeLine("ERROR: access denied!");
  521. return;
  522. }
  523. this.gameServer.loadConfig();
  524. this.gameServer.loadIpBanList();
  525. Logger.warn("CONFIGURATION RELOAD REQUEST FROM " + this.playerTracker.socket.remoteAddress + " as " + this.playerTracker.userAuth);
  526. this.writeLine("Configuration was Successfully Reloaded!");
  527. },
  528. login: function (args) {
  529. try {
  530. var username = args[1].trim();
  531. } catch (error) {
  532. this.writeLine("ERROR: you have to type in a username!");
  533. return;
  534. }
  535. try {
  536. var password = args[2].trim();
  537. } catch (error) {
  538. this.writeLine("ERROR: You have to type in a password!");
  539. return;
  540. }
  541. var user = this.userLogin(username, password);
  542. if (!user) {
  543. this.writeLine("ERROR: login failed!");
  544. return;
  545. }
  546. Logger.info(username + " Logined in as " + user.name + " from " + this.playerTracker.socket.remoteAddress + ":" + this.playerTracker.socket.remotePort);
  547. this.playerTracker.userRole = user.role;
  548. this.playerTracker.userAuth = user.name;
  549. var role = user.role;
  550. var name = user.name;
  551. this.admin = {
  552. name,
  553. username,
  554. }
  555. this.admins.push(this.admin);
  556. this.writeLine("Login done as \"" + user.name + "\"");
  557. return;
  558. },
  559. logout: function (args) {
  560. if (this.playerTracker.userRole == UserRoleEnum.GUEST) {
  561. this.writeLine("ERROR: not logged in");
  562. return;
  563. }
  564. var username = this.playerTracker.username;
  565. Logger.info(username + " Logged out from " + this.playerTracker.socket.remoteAddress + ":" + this.playerTracker.socket.remotePort);
  566. this.playerTracker.userRole = UserRoleEnum.GUEST;
  567. this.playerTracker.userAuth = null;
  568. this.writeLine("Logout done");
  569. },
  570. shutdown: function (args) {
  571. if (this.playerTracker.userRole != UserRoleEnum.ADMIN) {
  572. this.writeLine("ERROR: access denied!");
  573. return;
  574. }
  575. Logger.warn("SHUTDOWN REQUEST FROM " + this.playerTracker.socket.remoteAddress + " as " + this.playerTracker.userAuth);
  576. process.exit(0);
  577. },
  578. restart: function (args) {
  579. if (this.playerTracker.userRole != UserRoleEnum.ADMIN) {
  580. this.writeLine("ERROR: acces denied!");
  581. return;
  582. }
  583. Logger.warn("RESTART REQUEST FROM " + this.playerTracker.socket.remoteAddress + " as " + this.playerTracker.userAuth);
  584. process.exit(3);
  585. }
  586. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement