Guest User

Untitled

a guest
Jan 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. /*
  2. * Sets the server up for a new game type
  3. * Recieves post with
  4. * {
  5. * server_id: <id of server>,
  6. * rules: <ruleset json>,
  7. * game_type_id: <id integer>,
  8. * game_type_name: <string (6v6 Standard, Highlander, etc)>,
  9. * positions: <position json>
  10. * maps: [ "koth_viaduct", "cp_badlands" ]
  11. * }
  12. * Rules looks like:
  13. * {
  14. * class_limits: {
  15. * both: { heavy: 1, soldier: 2, scout: 2, sniper: 2, medic: 1, engy: 2, pyro: 2, spy: 2, demo: 1 }
  16. * },
  17. * item_blacklist: ['The Amputator', 'The Vita-Saw', 'The Sandman', 'The Shortstop', 'Mad Milk', 'The Candy Cane', 'The Boston Basher', 'Bonk! Atomic Punch', 'The Ullapool Caber',
  18. 'The Loch-n-Load', 'The Claidheamohmor', 'The Wrangler', 'The Jag', 'Natascha', 'Gloves of Running Urgently', 'The Buffalo Steak Sandvich', 'The Brass Beast', 'Warrior\'s Spirit', 'Fists of Steel', 'The Sandvich', 'The Powerjack', 'The Back Scratcher', 'The Sydney Sleeper', 'The Battalion\'s Backup']
  19. * };
  20. * }
  21. * Positions looks like
  22. * { 24(position_id):
  23. * {
  24. * title: "Roaming Soldier",
  25. * limit: 1,
  26. * classes: [ 'soldier', 'heavy', 'pyro' ],
  27. * starting_class: 'soldier',
  28. * }
  29. * 28:
  30. * {
  31. * title: "Demoman",
  32. * limit: 1,
  33. * classes: [ 'demo' ],
  34. * starting_class: 'demo'
  35. * }
  36. *
  37. * }
  38. */
  39. exports.setupGameType = function(req, res) {
  40. Auth.checkAuth(auth).then(function(result) {
  41. // To send an rcon command
  42. // rcon.send("rcon command");
  43. // To write to the local filesystem key value store
  44. // msg_db.set("server1_game_type", "1")
  45. // To send information back to the Play server
  46. // play.request("/message/serverReport", { abunch: 'of', server: 'info' });
  47.  
  48. // These server.cfg settings only need to be set in server.cfg one time ever
  49. GameConfig.write("server.cfg", "mp_timelimit", "0");
  50. GameConfig.write("server.cfg", "mp_winlimit", "100"); //not sure of exact value, but this'll work
  51. GameConfig.write("server.cfg", "mp_teams_unbalance_limit", "0");
  52. GameConfig.write("server.cfg", "sv_allow_votes", "0");
  53. GameConfig.write("server.cfg", "mp_tournament", "0");
  54. GameConfig.write("server.cfg", "sv_alltalk", "0");
  55. GameConfig.write("server.cfg", "tf_use_fixed_weaponspreads", "1");
  56. GameConfig.write("server.cfg", "tf_damage_disablespread", "1");
  57. GameConfig.write("server.cfg", "tf_weapon_criticals", "0");
  58. // We might also need to configure who can see dead players' chat and specs' chat eventually
  59.  
  60. // Remove the antiflood.smx and other unnecessary SourceMod plugins' files eventually
  61. rcon.send("sm plugins unload antiflood");
  62.  
  63. rcon.send("pubcomp_reset_game_setup");
  64. rcon.send('pubcomp_set_warmup_mod "SOAP"');
  65. rcon.send('pubcomp_set_class_limit "both" "1" "2"'); //scout
  66. rcon.send('pubcomp_set_class_limit "both" "2" "2"'); //soldier
  67. rcon.send('pubcomp_set_class_limit "both" "3" "2"'); //pyro
  68. rcon.send('pubcomp_set_class_limit "both" "4" "1"'); //demoman
  69. rcon.send('pubcomp_set_class_limit "both" "5" "1"'); //heavy
  70. rcon.send('pubcomp_set_class_limit "both" "6" "2"'); //engineer
  71. rcon.send('pubcomp_set_class_limit "both" "7" "1"'); //medic
  72. rcon.send('pubcomp_set_class_limit "both" "8" "2"'); //sniper
  73. rcon.send('pubcomp_set_class_limit "both" "9" "2"'); //spy
  74. rcon.send('pubcomp_add_game_command "mp_winlimit 5"'); //4 if viaduct
  75. rcon.send('pubcomp_add_game_command "mp_timelimit 30"');
  76. rcon.send('pubcomp_set_needed_ready "12"');
  77. rcon.send("mp_tournament_whitelist cfg/pubcomp/weapon_whitelist.cfg");
  78. });
  79. }
  80.  
  81. /*
  82. * Adds a player to the whitelist.
  83. * Post
  84. * {
  85. * "steam_id": <player's steam id>,
  86. * "position_votes": { <position_id>: <vote_weight integer> },
  87. * "map_votes": { <map_id>
  88. * }
  89. */
  90. exports.addPlayer = function(req, res) {
  91. Auth.checkAuth(auth).then(function(result) {
  92. rcon.send('pubcomp_add_steamid "STEAMID"'); //put in actual steamid
  93. rcon.send('pubcomp_add_name "STEAMID" "PLAYERSNAME"'); //put in actual id and name
  94. });
  95. }
  96. /*
  97. * Removes a player from the whitelist and kicks them from the server.
  98. * Post
  99. * {
  100. * "steam_id": <player's steam id>,
  101. * "server_id": <integer, id of server>
  102. * "reason": { <string, reason for kick>
  103. * }
  104. */
  105. exports.removePlayer = function(req, res) {
  106. Auth.checkAuth(auth).then(function(result) {
  107. //I don't have a function for unwhitelisting one player yet
  108. });
  109. }
  110.  
  111. /*
  112. * Kicks everyone from the server and resets the game to warmup mode.
  113. * Post
  114. * {
  115. * "server_id": <integer, id of server>
  116. * }
  117. */
  118. exports.clearServer = function(req, res) {
  119. Auth.checkAuth(auth).then(function(result) {
  120. rcon.send("pubcomp_reset_game_setup");
  121. rcon.send("pubcomp_kick_all_nonwhitelist");
  122. });
  123. }
  124.  
  125. 1
  126. 2
  127. 3
  128. 4
  129. 5
  130. 6
  131. 7
  132. 8
  133. 9
  134. /*
  135. * Indicates game is ready to start, starts parsing the log
  136. * player_to_position: { "<steam_id>": "<position_id>", "<steam_id>": "<position_id>" }
  137. * map: "cp_badlands"
  138. */
  139. exports.gameReady = function(req, res) {
  140. Auth.checkAuth(auth).then(function(result) {
  141. rcon.send("changelevel cp_badlands"); //or koth_viaduct etc.
  142. //run these three commands in a loop for each player with their respective information (12 times)
  143. rcon.send('pubcomp_set_player_team "STEAMID" "red"'); //replace with real id, and "red" or "blue"
  144. rcon.send('pubcomp_set_player_class "STEAMID" "2"'); //2 would be soldier, 3 pyro, 9 spy, etc.
  145. rcon.send('pubcomp_set_player_positions "STEAMID" "1-2-3-9"'); // actual positions follows
  146. /*
  147. Roaming soldier:"2-5-3"
  148. Demoman:"4"
  149. Medic:"7"
  150. Scouts:"1-8-3-6" if you want scout, sniper, pyro, and engie
  151. Pocket soldier:"2-5" if you want soldier and heavy
  152. */
  153. rcon.send("pubcomp_kick_all_nonwhitelist"); //just in case
  154. rcon.send("pubcomp_let_players_ready"); //good to go!
  155. });
  156. }
Add Comment
Please, Sign In to add comment