Advertisement
Guest User

Untitled

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