Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Sets the server up for a new game type
- * Recieves post with
- * {
- * server_id: <id of server>,
- * rules: <ruleset json>,
- * game_type_id: <id integer>,
- * game_type_name: <string (6v6 Standard, Highlander, etc)>,
- * positions: <position json>
- * maps: [ "koth_viaduct", "cp_badlands" ]
- * }
- * Rules looks like:
- * {
- * class_limits: {
- * both: { heavy: 1, soldier: 2, scout: 2, sniper: 2, medic: 1, engy: 2, pyro: 2, spy: 2, demo: 1 }
- * },
- * 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',
- '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']
- * };
- * }
- * Positions looks like
- * { 24(position_id):
- * {
- * title: "Roaming Soldier",
- * limit: 1,
- * classes: [ 'soldier', 'heavy', 'pyro' ],
- * starting_class: 'soldier',
- * }
- * 28:
- * {
- * title: "Demoman",
- * limit: 1,
- * classes: [ 'demo' ],
- * starting_class: 'demo'
- * }
- *
- * }
- */
- exports.setupGameType = function(req, res) {
- Auth.checkAuth(auth).then(function(result) {
- // To send an rcon command
- // rcon.send("rcon command");
- // To write to the local filesystem key value store
- // msg_db.set("server1_game_type", "1")
- // To send information back to the Play server
- // play.request("/message/serverReport", { abunch: 'of', server: 'info' });
- // These server.cfg settings only need to be set in server.cfg one time ever
- GameConfig.write("server.cfg", "mp_timelimit", "0");
- GameConfig.write("server.cfg", "mp_winlimit", "100"); //not sure of exact value, but this'll work
- GameConfig.write("server.cfg", "mp_teams_unbalance_limit", "0");
- GameConfig.write("server.cfg", "sv_allow_votes", "0");
- GameConfig.write("server.cfg", "mp_tournament", "0");
- GameConfig.write("server.cfg", "sv_alltalk", "0");
- GameConfig.write("server.cfg", "tf_use_fixed_weaponspreads", "1");
- GameConfig.write("server.cfg", "tf_damage_disablespread", "1");
- GameConfig.write("server.cfg", "tf_weapon_criticals", "0");
- //GameConfig.write("server.cfg", "mp_tournament_whitelist", "cfg/pubcomp/weapon_whitelist.cfg"); eventually
- rcon.send("mp_tournament_whitelist cfg/pubcomp/weapon_whitelist.cfg"); // for now
- // We might also need to configure who can see dead players' chat and specs' chat eventually
- // Remove the antiflood.smx and other unnecessary SourceMod plugins' files eventually
- rcon.send("sm plugins unload antiflood");
- rcon.send("pubcomp_reset_game_setup");
- rcon.send('pubcomp_set_warmup_mod "SOAP"');
- rcon.send('pubcomp_set_class_limit "both" "1" "2"'); //scout
- rcon.send('pubcomp_set_class_limit "both" "2" "2"'); //soldier
- rcon.send('pubcomp_set_class_limit "both" "3" "2"'); //pyro
- rcon.send('pubcomp_set_class_limit "both" "4" "1"'); //demoman
- rcon.send('pubcomp_set_class_limit "both" "5" "1"'); //heavy
- rcon.send('pubcomp_set_class_limit "both" "6" "2"'); //engineer
- rcon.send('pubcomp_set_class_limit "both" "7" "1"'); //medic
- rcon.send('pubcomp_set_class_limit "both" "8" "2"'); //sniper
- rcon.send('pubcomp_set_class_limit "both" "9" "2"'); //spy
- rcon.send('pubcomp_add_game_command "mp_winlimit 5"'); //4 if viaduct
- rcon.send('pubcomp_add_game_command "mp_timelimit 30"');
- rcon.send('pubcomp_set_needed_ready "12"');
- rcon.send("changelevel cp_badlands"); //where cp_badlands is a random soap-compatible map
- });
- }
- /*
- * Adds a player to the whitelist.
- * Post
- * {
- * "steam_id": <player's steam id>,
- * "position_votes": { <position_id>: <vote_weight integer> },
- * "map_votes": { <map_id>
- * }
- */
- exports.addPlayer = function(req, res) {
- Auth.checkAuth(auth).then(function(result) {
- rcon.send('pubcomp_add_steamid "STEAMID"'); //put in actual steamid
- rcon.send('pubcomp_add_name "STEAMID" "PLAYERSNAME"'); //put in actual id and name
- });
- }
- /*
- * Removes a player from the whitelist and kicks them from the server.
- * Post
- * {
- * "steam_id": <player's steam id>,
- * "server_id": <integer, id of server>
- * "reason": { <string, reason for kick>
- * }
- */
- exports.removePlayer = function(req, res) {
- Auth.checkAuth(auth).then(function(result) {
- //I don't have a function for unwhitelisting one player yet
- });
- }
- /*
- * Kicks everyone from the server and resets the game to warmup mode.
- * Post
- * {
- * "server_id": <integer, id of server>
- * }
- */
- exports.clearServer = function(req, res) {
- Auth.checkAuth(auth).then(function(result) {
- rcon.send("pubcomp_reset_game_setup");
- rcon.send("pubcomp_kick_all_nonwhitelist");
- });
- }
- /*
- * Indicates game is ready to start, starts parsing the log
- * player_to_position: { "<steam_id>": "<position_id>", "<steam_id>": "<position_id>" }
- * map: "cp_badlands"
- */
- exports.gameReady = function(req, res) {
- Auth.checkAuth(auth).then(function(result) {
- //run these three commands in a loop for each player with their respective information (12 times)
- rcon.send('pubcomp_set_player_team "STEAMID" "red"'); //replace with real id, and "red" or "blue"
- rcon.send('pubcomp_set_player_class "STEAMID" "2"'); //2 would be soldier, 3 pyro, 9 spy, etc.
- rcon.send('pubcomp_set_player_positions "STEAMID" "1-2-3-9"'); // actual positions follows
- /*
- Roaming soldier:"2-5-3"
- Demoman:"4"
- Medic:"7"
- Scouts:"1-8-3-6" if you want scout, sniper, pyro, and engie
- Pocket soldier:"2-5" if you want soldier and heavy
- */
- rcon.send("pubcomp_kick_all_nonwhitelist"); //just in case
- rcon.send("pubcomp_let_players_ready"); //good to go! only start seriously parsing the log for stats once Match Starts
- rcon.send("changelevel cp_badlands"); //or koth_viaduct - only if not on same map already
- });
- }
Add Comment
Please, Sign In to add comment