daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Jan 17th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     //GameConfig.write("server.cfg", "mp_tournament_whitelist", "cfg/pubcomp/weapon_whitelist.cfg"); eventually
  59.     rcon.send("mp_tournament_whitelist cfg/pubcomp/weapon_whitelist.cfg"); // for now
  60.     // We might also need to configure who can see dead players' chat and specs' chat eventually
  61.  
  62.     // Remove the antiflood.smx and other unnecessary SourceMod plugins' files eventually
  63.     rcon.send("sm plugins unload antiflood");
  64.  
  65.     rcon.send("pubcomp_reset_game_setup");
  66.     rcon.send('pubcomp_set_warmup_mod "SOAP"');
  67.     rcon.send('pubcomp_set_class_limit "both" "1" "2"'); //scout
  68.     rcon.send('pubcomp_set_class_limit "both" "2" "2"'); //soldier
  69.     rcon.send('pubcomp_set_class_limit "both" "3" "2"'); //pyro
  70.     rcon.send('pubcomp_set_class_limit "both" "4" "1"'); //demoman
  71.     rcon.send('pubcomp_set_class_limit "both" "5" "1"'); //heavy
  72.     rcon.send('pubcomp_set_class_limit "both" "6" "2"'); //engineer
  73.     rcon.send('pubcomp_set_class_limit "both" "7" "1"'); //medic
  74.     rcon.send('pubcomp_set_class_limit "both" "8" "2"'); //sniper
  75.     rcon.send('pubcomp_set_class_limit "both" "9" "2"'); //spy
  76.     rcon.send('pubcomp_add_game_command "mp_winlimit 5"'); //4 if viaduct
  77.     rcon.send('pubcomp_add_game_command "mp_timelimit 30"');
  78.     rcon.send('pubcomp_set_needed_ready "12"');
  79.  
  80.     rcon.send("changelevel cp_badlands"); //where cp_badlands is a random soap-compatible map
  81.   });
  82. }
  83.  
  84. /*
  85. * Adds a player to the whitelist.
  86. * Post
  87. * {
  88. *   "steam_id": <player's steam id>,
  89. *   "position_votes": { <position_id>: <vote_weight integer> },
  90. *   "map_votes": { <map_id>
  91. * }
  92. */
  93. exports.addPlayer = function(req, res) {
  94.   Auth.checkAuth(auth).then(function(result) {
  95.     rcon.send('pubcomp_add_steamid "STEAMID"'); //put in actual steamid
  96.     rcon.send('pubcomp_add_name "STEAMID" "PLAYERSNAME"'); //put in actual id and name
  97.   });
  98. }
  99. /*
  100. * Removes a player from the whitelist and kicks them from the server.
  101. * Post
  102. * {
  103. *   "steam_id": <player's steam id>,
  104. *   "server_id": <integer, id of server>
  105. *   "reason": { <string, reason for kick>
  106. * }
  107. */
  108. exports.removePlayer = function(req, res) {
  109.   Auth.checkAuth(auth).then(function(result) {
  110.     //I don't have a function for unwhitelisting one player yet
  111.   });
  112. }
  113.  
  114. /*
  115. * Kicks everyone from the server and resets the game to warmup mode.
  116. * Post
  117. * {
  118. *   "server_id": <integer, id of server>
  119. * }
  120. */
  121. exports.clearServer = function(req, res) {
  122.   Auth.checkAuth(auth).then(function(result) {
  123.     rcon.send("pubcomp_reset_game_setup");
  124.     rcon.send("pubcomp_kick_all_nonwhitelist");
  125.   });
  126. }
  127. /*
  128. * Indicates game is ready to start, starts parsing the log
  129. * player_to_position: { "<steam_id>": "<position_id>", "<steam_id>": "<position_id>" }
  130. * map: "cp_badlands"
  131. */
  132. exports.gameReady = function(req, res) {
  133.   Auth.checkAuth(auth).then(function(result) {
  134.     //run these three commands in a loop for each player with their respective information (12 times)
  135.     rcon.send('pubcomp_set_player_team "STEAMID" "red"'); //replace with real id, and "red" or "blue"
  136.     rcon.send('pubcomp_set_player_class "STEAMID" "2"'); //2 would be soldier, 3 pyro, 9 spy, etc.
  137.     rcon.send('pubcomp_set_player_positions "STEAMID" "1-2-3-9"'); // actual positions follows
  138.     /*
  139.     Roaming soldier:"2-5-3"
  140.     Demoman:"4"
  141.     Medic:"7"
  142.     Scouts:"1-8-3-6" if you want scout, sniper, pyro, and engie
  143.     Pocket soldier:"2-5" if you want soldier and heavy
  144.     */
  145.     rcon.send("pubcomp_kick_all_nonwhitelist"); //just in case
  146.     rcon.send("pubcomp_let_players_ready"); //good to go! only start seriously parsing the log for stats once Match Starts
  147.     rcon.send("changelevel cp_badlands"); //or koth_viaduct - only if not on same map already
  148.   });
  149. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top