From c96cf2e93ec0277cfc3e9d6a43b312a7e864cc50 Mon Sep 17 00:00:00 2001 From: shoopea Date: Tue, 29 Oct 2024 20:15:00 +0100 Subject: [PATCH] start revamp --- cfg/knife.cfg | 22 ----- cfg/{live16.cfg => live_casual_16.cfg} | 21 ++--- cfg/{live24.cfg => live_casual_24.cfg} | 21 ++--- cfg/live_competitive_16.cfg | 117 +++++++++++++++++++++++++ cfg/live_competitive_24.cfg | 117 +++++++++++++++++++++++++ cfg/live_restart.cfg | 6 ++ cfg/live_wingman.cfg | 5 +- cfg/warmup_16.cfg | 46 ++++++++++ cfg/{warmup.cfg => warmup_24.cfg} | 5 +- cfg/warmup_restart.cfg | 4 + public/js/console.js | 6 -- routes/game.js | 117 +++++++++++-------------- views/manage.ejs | 30 +++---- 13 files changed, 368 insertions(+), 149 deletions(-) delete mode 100644 cfg/knife.cfg rename cfg/{live16.cfg => live_casual_16.cfg} (92%) rename cfg/{live24.cfg => live_casual_24.cfg} (92%) create mode 100644 cfg/live_competitive_16.cfg create mode 100644 cfg/live_competitive_24.cfg create mode 100644 cfg/live_restart.cfg create mode 100644 cfg/warmup_16.cfg rename cfg/{warmup.cfg => warmup_24.cfg} (93%) create mode 100644 cfg/warmup_restart.cfg diff --git a/cfg/knife.cfg b/cfg/knife.cfg deleted file mode 100644 index 64c870f..0000000 --- a/cfg/knife.cfg +++ /dev/null @@ -1,22 +0,0 @@ -mp_ct_default_secondary "" -mp_free_armor 1 -mp_freezetime 10 -mp_give_player_c4 0 -mp_maxmoney 0 -mp_respawn_immunitytime 0 -mp_respawn_on_death_ct 0 -mp_respawn_on_death_t 0 -mp_roundtime 1.92 -mp_roundtime_defuse 1.92 -mp_roundtime_hostage 1.92 -mp_t_default_secondary "" -mp_round_restart_delay 3 -mp_team_intro_time 0 -say Knife! -say Knife! -say Knife! -say Knife! -say Knife! -say Knife! -mp_restartgame 1 -mp_warmup_end \ No newline at end of file diff --git a/cfg/live16.cfg b/cfg/live_casual_16.cfg similarity index 92% rename from cfg/live16.cfg rename to cfg/live_casual_16.cfg index 8a01836..4de5be2 100644 --- a/cfg/live16.cfg +++ b/cfg/live_casual_16.cfg @@ -11,6 +11,7 @@ cash_player_killed_enemy_factor 1 cash_player_killed_hostage -1000 cash_player_killed_teammate -300 cash_player_rescued_hostage 1000 +cash_team_bonus_shorthanded 0 cash_team_elimination_bomb_map 3250 cash_team_elimination_hostage_map_ct 3000 cash_team_elimination_hostage_map_t 3000 @@ -18,6 +19,7 @@ cash_team_hostage_alive 0 cash_team_hostage_interaction 600 cash_team_loser_bonus 1400 cash_team_loser_bonus_consecutive_rounds 500 +cash_team_loser_bonus_shorthanded 0 cash_team_planted_bomb_but_defused 800 cash_team_rescued_hostage 600 cash_team_terrorist_win_bomb 3500 @@ -76,12 +78,16 @@ mp_roundtime 1.92 mp_roundtime_defuse 1.92 mp_roundtime_hostage 1.92 mp_solid_teammates 1 +mp_spectators_max 20 mp_starting_losses 1 mp_startmoney 800 mp_t_default_melee weapon_knife mp_t_default_primary "" mp_t_default_secondary weapon_glock mp_teamcashawards 1 +mp_team_intro_time 0 +mp_team_timeout_max 4 +mp_team_timeout_time 30 mp_timelimit 0 mp_weapons_allow_map_placed 1 mp_weapons_allow_zeus 1 @@ -107,18 +113,5 @@ sv_occlude_players 1 sv_talk_enemy_dead 0 sv_talk_enemy_living 0 sv_voiceenable 1 -tv_relayvoice 1 -mp_team_timeout_max 4 -mp_team_timeout_time 30 sv_vote_command_delay 0 -cash_team_bonus_shorthanded 0 -cash_team_loser_bonus_shorthanded 0 -mp_spectators_max 20 -mp_team_intro_time 0 -say Match is live! -say Match is live! -say Match is live! -say use call timeout for TAC and type Tech ( Admin will pause the game ) -say use call timeout for TAC and type Tech ( Admin will pause the game ) -mp_restartgame 3 -mp_warmup_end \ No newline at end of file +tv_relayvoice 1 \ No newline at end of file diff --git a/cfg/live24.cfg b/cfg/live_casual_24.cfg similarity index 92% rename from cfg/live24.cfg rename to cfg/live_casual_24.cfg index a70ee3a..91ca391 100644 --- a/cfg/live24.cfg +++ b/cfg/live_casual_24.cfg @@ -11,6 +11,7 @@ cash_player_killed_enemy_factor 1 cash_player_killed_hostage -1000 cash_player_killed_teammate -300 cash_player_rescued_hostage 1000 +cash_team_bonus_shorthanded 0 cash_team_elimination_bomb_map 3250 cash_team_elimination_hostage_map_ct 3000 cash_team_elimination_hostage_map_t 3000 @@ -18,6 +19,7 @@ cash_team_hostage_alive 0 cash_team_hostage_interaction 600 cash_team_loser_bonus 1400 cash_team_loser_bonus_consecutive_rounds 500 +cash_team_loser_bonus_shorthanded 0 cash_team_planted_bomb_but_defused 800 cash_team_rescued_hostage 600 cash_team_terrorist_win_bomb 3500 @@ -76,12 +78,16 @@ mp_roundtime 1.92 mp_roundtime_defuse 1.92 mp_roundtime_hostage 1.92 mp_solid_teammates 1 +mp_spectators_max 20 mp_starting_losses 1 mp_startmoney 800 mp_t_default_melee weapon_knife mp_t_default_primary "" mp_t_default_secondary weapon_glock mp_teamcashawards 1 +mp_team_intro_time 0 +mp_team_timeout_max 4 +mp_team_timeout_time 30 mp_timelimit 0 mp_weapons_allow_map_placed 1 mp_weapons_allow_zeus 1 @@ -107,18 +113,5 @@ sv_occlude_players 1 sv_talk_enemy_dead 0 sv_talk_enemy_living 0 sv_voiceenable 1 -tv_relayvoice 1 -mp_team_timeout_max 4 -mp_team_timeout_time 30 sv_vote_command_delay 0 -cash_team_bonus_shorthanded 0 -cash_team_loser_bonus_shorthanded 0 -mp_spectators_max 20 -mp_team_intro_time 0 -say Match is live! -say Match is live! -say Match is live! -say use call timeout for TAC and type Tech ( Admin will pause the game ) -say use call timeout for TAC and type Tech ( Admin will pause the game ) -mp_restartgame 3 -mp_warmup_end \ No newline at end of file +tv_relayvoice 1 \ No newline at end of file diff --git a/cfg/live_competitive_16.cfg b/cfg/live_competitive_16.cfg new file mode 100644 index 0000000..4de5be2 --- /dev/null +++ b/cfg/live_competitive_16.cfg @@ -0,0 +1,117 @@ +ammo_grenade_limit_default 1 +ammo_grenade_limit_flashbang 2 +ammo_grenade_limit_total 4 +bot_quota 0 +cash_player_bomb_defused 300 +cash_player_bomb_planted 300 +cash_player_damage_hostage -30 +cash_player_interact_with_hostage 300 +cash_player_killed_enemy_default 300 +cash_player_killed_enemy_factor 1 +cash_player_killed_hostage -1000 +cash_player_killed_teammate -300 +cash_player_rescued_hostage 1000 +cash_team_bonus_shorthanded 0 +cash_team_elimination_bomb_map 3250 +cash_team_elimination_hostage_map_ct 3000 +cash_team_elimination_hostage_map_t 3000 +cash_team_hostage_alive 0 +cash_team_hostage_interaction 600 +cash_team_loser_bonus 1400 +cash_team_loser_bonus_consecutive_rounds 500 +cash_team_loser_bonus_shorthanded 0 +cash_team_planted_bomb_but_defused 800 +cash_team_rescued_hostage 600 +cash_team_terrorist_win_bomb 3500 +cash_team_win_by_defusing_bomb 3500 +cash_team_win_by_hostage_rescue 2900 +cash_team_win_by_time_running_out_bomb 3250 +cash_team_win_by_time_running_out_hostage 3250 +ff_damage_reduction_bullets 0.33 +ff_damage_reduction_grenade 0.85 +ff_damage_reduction_grenade_self 1 +ff_damage_reduction_other 0.4 +mp_afterroundmoney 0 +mp_autokick 0 +mp_autoteambalance 0 +mp_backup_restore_load_autopause 1 +mp_backup_round_auto 1 +mp_buy_anywhere 0 +mp_buy_during_immunity 0 +mp_buytime 20 +mp_c4timer 40 +mp_ct_default_melee weapon_knife +mp_ct_default_primary "" +mp_ct_default_secondary weapon_hkp2000 +mp_death_drop_defuser 1 +mp_death_drop_grenade 2 +mp_death_drop_gun 1 +mp_defuser_allocation 0 +mp_display_kill_assists 1 +mp_endmatch_votenextmap 0 +mp_forcecamera 1 +mp_free_armor 0 +mp_freezetime 18 +mp_friendlyfire 1 +mp_give_player_c4 1 +mp_halftime 1 +mp_halftime_duration 15 +mp_halftime_pausetimer 0 +mp_ignore_round_win_conditions 0 +mp_limitteams 0 +mp_match_can_clinch 1 +mp_match_end_restart 0 +mp_maxmoney 16000 +mp_maxrounds 16 +mp_molotovusedelay 0 +mp_overtime_enable 1 +mp_overtime_halftime_pausetimer 0 +mp_overtime_maxrounds 4 +mp_overtime_startmoney 10000 +mp_playercashawards 1 +mp_randomspawn 0 +mp_respawn_immunitytime 0 +mp_respawn_on_death_ct 0 +mp_respawn_on_death_t 0 +mp_round_restart_delay 5 +mp_roundtime 1.92 +mp_roundtime_defuse 1.92 +mp_roundtime_hostage 1.92 +mp_solid_teammates 1 +mp_spectators_max 20 +mp_starting_losses 1 +mp_startmoney 800 +mp_t_default_melee weapon_knife +mp_t_default_primary "" +mp_t_default_secondary weapon_glock +mp_teamcashawards 1 +mp_team_intro_time 0 +mp_team_timeout_max 4 +mp_team_timeout_time 30 +mp_timelimit 0 +mp_weapons_allow_map_placed 1 +mp_weapons_allow_zeus 1 +mp_weapons_glow_on_ground 0 +mp_win_panel_display_time 3 +occlusion_test_async 0 +spec_freeze_deathanim_time 0 +spec_freeze_panel_extended_time 0 +spec_freeze_time 2 +spec_freeze_time_lock 2 +spec_replay_enable 0 +sv_allow_votes 1 +sv_auto_full_alltalk_during_warmup_half_end 0 +sv_coaching_enabled 1 +sv_competitive_official_5v5 1 +sv_damage_print_enable 0 +sv_deadtalk 1 +sv_hibernate_postgame_delay 300 +sv_holiday_mode 0 +sv_ignoregrenaderadio 0 +sv_infinite_ammo 0 +sv_occlude_players 1 +sv_talk_enemy_dead 0 +sv_talk_enemy_living 0 +sv_voiceenable 1 +sv_vote_command_delay 0 +tv_relayvoice 1 \ No newline at end of file diff --git a/cfg/live_competitive_24.cfg b/cfg/live_competitive_24.cfg new file mode 100644 index 0000000..91ca391 --- /dev/null +++ b/cfg/live_competitive_24.cfg @@ -0,0 +1,117 @@ +ammo_grenade_limit_default 1 +ammo_grenade_limit_flashbang 2 +ammo_grenade_limit_total 4 +bot_quota 0 +cash_player_bomb_defused 300 +cash_player_bomb_planted 300 +cash_player_damage_hostage -30 +cash_player_interact_with_hostage 300 +cash_player_killed_enemy_default 300 +cash_player_killed_enemy_factor 1 +cash_player_killed_hostage -1000 +cash_player_killed_teammate -300 +cash_player_rescued_hostage 1000 +cash_team_bonus_shorthanded 0 +cash_team_elimination_bomb_map 3250 +cash_team_elimination_hostage_map_ct 3000 +cash_team_elimination_hostage_map_t 3000 +cash_team_hostage_alive 0 +cash_team_hostage_interaction 600 +cash_team_loser_bonus 1400 +cash_team_loser_bonus_consecutive_rounds 500 +cash_team_loser_bonus_shorthanded 0 +cash_team_planted_bomb_but_defused 800 +cash_team_rescued_hostage 600 +cash_team_terrorist_win_bomb 3500 +cash_team_win_by_defusing_bomb 3500 +cash_team_win_by_hostage_rescue 2900 +cash_team_win_by_time_running_out_bomb 3250 +cash_team_win_by_time_running_out_hostage 3250 +ff_damage_reduction_bullets 0.33 +ff_damage_reduction_grenade 0.85 +ff_damage_reduction_grenade_self 1 +ff_damage_reduction_other 0.4 +mp_afterroundmoney 0 +mp_autokick 0 +mp_autoteambalance 0 +mp_backup_restore_load_autopause 1 +mp_backup_round_auto 1 +mp_buy_anywhere 0 +mp_buy_during_immunity 0 +mp_buytime 20 +mp_c4timer 40 +mp_ct_default_melee weapon_knife +mp_ct_default_primary "" +mp_ct_default_secondary weapon_hkp2000 +mp_death_drop_defuser 1 +mp_death_drop_grenade 2 +mp_death_drop_gun 1 +mp_defuser_allocation 0 +mp_display_kill_assists 1 +mp_endmatch_votenextmap 0 +mp_forcecamera 1 +mp_free_armor 0 +mp_freezetime 18 +mp_friendlyfire 1 +mp_give_player_c4 1 +mp_halftime 1 +mp_halftime_duration 15 +mp_halftime_pausetimer 0 +mp_ignore_round_win_conditions 0 +mp_limitteams 0 +mp_match_can_clinch 1 +mp_match_end_restart 0 +mp_maxmoney 16000 +mp_maxrounds 24 +mp_molotovusedelay 0 +mp_overtime_enable 1 +mp_overtime_halftime_pausetimer 0 +mp_overtime_maxrounds 6 +mp_overtime_startmoney 10000 +mp_playercashawards 1 +mp_randomspawn 0 +mp_respawn_immunitytime 0 +mp_respawn_on_death_ct 0 +mp_respawn_on_death_t 0 +mp_round_restart_delay 5 +mp_roundtime 1.92 +mp_roundtime_defuse 1.92 +mp_roundtime_hostage 1.92 +mp_solid_teammates 1 +mp_spectators_max 20 +mp_starting_losses 1 +mp_startmoney 800 +mp_t_default_melee weapon_knife +mp_t_default_primary "" +mp_t_default_secondary weapon_glock +mp_teamcashawards 1 +mp_team_intro_time 0 +mp_team_timeout_max 4 +mp_team_timeout_time 30 +mp_timelimit 0 +mp_weapons_allow_map_placed 1 +mp_weapons_allow_zeus 1 +mp_weapons_glow_on_ground 0 +mp_win_panel_display_time 3 +occlusion_test_async 0 +spec_freeze_deathanim_time 0 +spec_freeze_panel_extended_time 0 +spec_freeze_time 2 +spec_freeze_time_lock 2 +spec_replay_enable 0 +sv_allow_votes 1 +sv_auto_full_alltalk_during_warmup_half_end 0 +sv_coaching_enabled 1 +sv_competitive_official_5v5 1 +sv_damage_print_enable 0 +sv_deadtalk 1 +sv_hibernate_postgame_delay 300 +sv_holiday_mode 0 +sv_ignoregrenaderadio 0 +sv_infinite_ammo 0 +sv_occlude_players 1 +sv_talk_enemy_dead 0 +sv_talk_enemy_living 0 +sv_voiceenable 1 +sv_vote_command_delay 0 +tv_relayvoice 1 \ No newline at end of file diff --git a/cfg/live_restart.cfg b/cfg/live_restart.cfg new file mode 100644 index 0000000..1c9d175 --- /dev/null +++ b/cfg/live_restart.cfg @@ -0,0 +1,6 @@ + +say Match is live! +say Match is live! +say Match is live! +mp_restartgame 3 +mp_warmup_end \ No newline at end of file diff --git a/cfg/live_wingman.cfg b/cfg/live_wingman.cfg index 6a482b7..0435a4f 100644 --- a/cfg/live_wingman.cfg +++ b/cfg/live_wingman.cfg @@ -108,7 +108,4 @@ sv_occlude_players 1 sv_talk_enemy_dead 0 sv_talk_enemy_living 0 sv_voiceenable 1 -tv_relayvoice 0 -say Match is live! -say Match is live! -say Match is live! \ No newline at end of file +tv_relayvoice 0 \ No newline at end of file diff --git a/cfg/warmup_16.cfg b/cfg/warmup_16.cfg new file mode 100644 index 0000000..56ce061 --- /dev/null +++ b/cfg/warmup_16.cfg @@ -0,0 +1,46 @@ +bot_kick +bot_quota 0 +mp_autokick 0 +mp_autoteambalance 0 +mp_buy_anywhere 0 +mp_buytime 15 +mp_death_drop_gun 0 +mp_free_armor 0 +mp_ignore_round_win_conditions 0 +mp_limitteams 0 +mp_radar_showall 0 +mp_respawn_on_death_ct 0 +mp_respawn_on_death_t 0 +mp_solid_teammates 0 +mp_spectators_max 20 +mp_maxmoney 16000 +mp_startmoney 16000 +mp_timelimit 0 +sv_alltalk 0 +sv_auto_full_alltalk_during_warmup_half_end 0 +sv_coaching_enabled 1 +sv_competitive_official_5v5 1 +sv_deadtalk 1 +sv_full_alltalk 0 +sv_grenade_trajectory 0 +sv_hibernate_when_empty 0 +mp_weapons_allow_typecount -1 +sv_infinite_ammo 0 +sv_showimpacts 0 +sv_voiceenable 1 +sm_cvar sv_mute_players_with_social_penalties 0 +sv_mute_players_with_social_penalties 0 +tv_relayvoice 1 +sv_cheats 0 +mp_ct_default_melee weapon_knife +mp_ct_default_secondary weapon_hkp2000 +mp_ct_default_primary "" +mp_t_default_melee weapon_knife +mp_t_default_secondary weapon_glock +mp_t_default_primary +mp_maxrounds 16 +mp_warmup_start +mp_warmup_pausetimer 1 +mp_warmuptime 9999 +cash_team_bonus_shorthanded 0 +cash_team_loser_bonus_shorthanded 0 \ No newline at end of file diff --git a/cfg/warmup.cfg b/cfg/warmup_24.cfg similarity index 93% rename from cfg/warmup.cfg rename to cfg/warmup_24.cfg index 6cd68d3..768ce67 100644 --- a/cfg/warmup.cfg +++ b/cfg/warmup_24.cfg @@ -43,7 +43,4 @@ mp_warmup_start mp_warmup_pausetimer 1 mp_warmuptime 9999 cash_team_bonus_shorthanded 0 -cash_team_loser_bonus_shorthanded 0 -say Warmup! -say Warmup! -say Warmup! \ No newline at end of file +cash_team_loser_bonus_shorthanded 0 \ No newline at end of file diff --git a/cfg/warmup_restart.cfg b/cfg/warmup_restart.cfg new file mode 100644 index 0000000..206d078 --- /dev/null +++ b/cfg/warmup_restart.cfg @@ -0,0 +1,4 @@ +mp_restartgame 1 +say Warmup! +say Warmup! +say Warmup! \ No newline at end of file diff --git a/public/js/console.js b/public/js/console.js index 15240aa..3fd0240 100644 --- a/public/js/console.js +++ b/public/js/console.js @@ -154,12 +154,6 @@ $(document).ready(function () { } }); - $('#knife_start').on('click', function () { - if (confirm("Are you sure you want to start the knife round?")) { - send_post_request('/api/start-knife'); - } - }); - $('#swap_team').on('click', function () { if (confirm("Are you sure you want to swap teams?")) { send_post_request('/api/swap-team'); diff --git a/routes/game.js b/routes/game.js index f5b4ded..775b9ff 100644 --- a/routes/game.js +++ b/routes/game.js @@ -14,28 +14,32 @@ router.post('/api/setup-game', is_authenticated, async (req, res) => { const team1 = req.body.team1; const team2 = req.body.team2; const selected_map = req.body.selectedMap; - const game_mode = req.body.game_mode.toString(); - // rcon.rcons[server_id].execute(`mp_teamname_1 "${team1}"`); - // rcon.rcons[server_id].execute(`mp_teamname_2 "${team2}"`); - // rcon.rcons[server_id].execute(`game_mode ${game_mode}`); + const game_sel = req.body.game_mode.toString(); + if (team1.trim() != "") { await rcon.execute_command(server_id, `mp_teamname_1 "${team1}"`); } + if (team2.trim() != "") { await rcon.execute_command(server_id, `mp_teamname_2 "${team2}"`); } - if (game_mode == "1") { + + if (game_sel == "1") { await rcon.execute_command(server_id, `game_mode 1`); - execute_cfg_on_server(server_id, './cfg/live16.cfg'); - } else if (game_mode == "2") { + execute_cfg_on_server(server_id, './cfg/live_competitive_16.cfg'); + } else if (game_sel == "2") { await rcon.execute_command(server_id, `game_mode 1`); - execute_cfg_on_server(server_id, './cfg/live24.cfg'); - } else if (game_mode == "3") { + execute_cfg_on_server(server_id, './cfg/live_competitive_24.cfg'); + } else if (game_sel == "3") { + await rcon.execute_command(server_id, `game_mode 1`); + execute_cfg_on_server(server_id, './cfg/live_casual_16.cfg'); + } else if (game_sel == "4") { + await rcon.execute_command(server_id, `game_mode 1`); + execute_cfg_on_server(server_id, './cfg/live_casual_24.cfg'); + } else if (game_sel == "5") { await rcon.execute_command(server_id, `game_mode 2`); execute_cfg_on_server(server_id, './cfg/live_wingman.cfg'); } - // rcon.rcons[server_id].execute(`mp_warmup_pausetimer 1`); - // rcon.rcons[server_id].execute(`changelevel ${selected_map}`); await rcon.execute_command(server_id, `mp_warmup_pausetimer 1`); await rcon.execute_command(server_id, `changelevel ${selected_map}`); @@ -44,7 +48,7 @@ router.post('/api/setup-game', is_authenticated, async (req, res) => { execute_cfg_on_server(server_id, './cfg/warmup.cfg'); }, 1000) - //return res.status(200).json({ message: 'Game Created!' }); + return res.status(200).json({ message: 'Game Created!' }); } catch (error) { console.log(error); res.status(500).json({ error: 'Internal server error' }); @@ -54,9 +58,8 @@ router.post('/api/setup-game', is_authenticated, async (req, res) => { router.post('/api/restart', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // rcon.rcons[server_id].execute('mp_restartgame 1'); await rcon.execute_command(server_id, `mp_restartgame 1`); - //return res.status(200).json({ message: 'Game restarted' }); + return res.status(200).json({ message: 'Game restarted' }); } catch (error) { console.log(error); res.status(500).json({ error: 'Internal server error' }); @@ -66,27 +69,10 @@ router.post('/api/restart', is_authenticated, async (req, res) => { router.post('/api/start-warmup', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // rcon.rcons[server_id].execute('mp_restartgame 1'); - await rcon.execute_command(server_id, `mp_restartgame 1`); execute_cfg_on_server(server_id, './cfg/warmup.cfg'); + execute_cfg_on_server(server_id, './cfg/warmup_restart.cfg'); - //return res.status(200).json({ message: 'Warmup started!' }); - } catch (error) { - console.log(error); - res.status(500).json({ error: 'Internal server error' }); - } -}); - -router.post('/api/start-knife', is_authenticated, async (req, res) => { - try { - const server_id = req.body.server_id; - // rcon.rcons[server_id].execute('mp_warmup_end'); - // rcon.rcons[server_id].execute('mp_restartgame 1'); - await rcon.execute_command(server_id, `mp_warmup_end`); - await rcon.execute_command(server_id, `mp_restartgame 1`); - execute_cfg_on_server(server_id, './cfg/knife.cfg'); - - //return res.status(200).json({ message: 'Knife started!' }); + return res.status(200).json({ message: 'Warmup started!' }); } catch (error) { console.log(error); res.status(500).json({ error: 'Internal server error' }); @@ -96,9 +82,8 @@ router.post('/api/start-knife', is_authenticated, async (req, res) => { router.post('/api/swap-team', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // rcon.rcons[server_id].execute('mp_swapteams'); await rcon.execute_command(server_id, `mp_swapteams`); - //return res.status(200).json({ message: 'Teams Swapped!' }); + return res.status(200).json({ message: 'Teams Swapped!' }); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } @@ -107,25 +92,36 @@ router.post('/api/swap-team', is_authenticated, async (req, res) => { router.post('/api/go-live', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // rcon.rcons[server_id].execute('mp_warmup_end'); - await rcon.execute_command(server_id, `mp_warmup_end`); - // const response = await rcon.rcons[server_id].execute('game_mode'); + const response = await rcon.execute_command(server_id, `game_mode`); const game_mode = response.split("=")[1].trim().toString(); - if (game_mode == "1") { - console.log("Executing live16.cfg") - execute_cfg_on_server(server_id, './cfg/live16.cfg'); + + response = await rcon.execute_command(server_id, `game_type`); + const game_type = response.split("=")[1].trim().toString(); + + response = await rcon.execute_command(server_id, `mp_maxrounds`); + const maxrounds = response.split("=")[1].trim().toString(); + + if (game_mode == "1" && maxrounds == "16") { + console.log("Executing live_competitive_16.cfg") + execute_cfg_on_server(server_id, './cfg/live_competitive_16.cfg'); + } else if (game_mode == "1" && maxrounds == "24") { + console.log("Executing live_competitive_24.cfg") + execute_cfg_on_server(server_id, './cfg/live_competitive_24.cfg'); + } else if (game_mode == "0" && maxrounds == "16") { + console.log("Executing live_casual_16.cfg") + execute_cfg_on_server(server_id, './cfg/live_casual_16.cfg'); + } else if (game_mode == "0" && maxrounds == "24") { + console.log("Executing live_casual_24.cfg") + execute_cfg_on_server(server_id, './cfg/live_casual_24.cfg'); } else if (game_mode == "2") { - console.log("Executing live24.cfg") - execute_cfg_on_server(server_id, './cfg/live24.cfg'); - } else if (game_mode == "3") { console.log("Executing live_wingman.cfg") execute_cfg_on_server(server_id, './cfg/live_wingman.cfg'); } - // rcon.rcons[server_id].execute('mp_restartgame 1'); - await rcon.execute_command(server_id, `mp_restartgame 1`); - //return res.status(200).json({ message: 'Match is live!!' }); + execute_cfg_on_server(server_id, './cfg/live_restart.cfg'); + + return res.status(200).json({ message: 'Match is live!!' }); } catch (error) { console.log(error); res.status(500).json({ error: 'Internal server error' }); @@ -136,10 +132,9 @@ router.post('/api/go-live', is_authenticated, async (req, res) => { router.post('/api/list-backups', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // const response = await rcon.rcons[server_id].execute('mp_backup_restore_list_files'); const response = await rcon.execute_command(server_id, "mp_backup_restore_list_files"); console.log('Server response:', response); - //return res.status(200).json({ message: response }); + return res.status(200).json({ message: response }); } catch (error) { console.log(error) res.status(500).json({ error: 'Internal server error' }); @@ -155,11 +150,9 @@ router.post('/api/restore-round', is_authenticated, async (req, res) => { round_number = "0" + round_number; } console.log(`SENDING mp_backup_restore_load_file backup_round${round_number}.txt`) - // rcon.rcons[server_id].execute(`mp_backup_restore_load_file backup_round${round_number}.txt`); - // rcon.rcons[server_id].execute('mp_pause_match'); await rcon.execute_command(server_id, `mp_backup_restore_load_file backup_round${round_number}.txt`); await rcon.execute_command(server_id, `mp_pause_match`); - //return res.status(200).json({ message: 'Round Restored!' }); + return res.status(200).json({ message: 'Round Restored!' }); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } @@ -168,17 +161,14 @@ router.post('/api/restore-round', is_authenticated, async (req, res) => { router.post('/api/restore-latest-backup', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // const response = await rcon.rcons[server_id].execute('mp_backup_round_file_last'); const response = await rcon.execute_command(server_id, `mp_backup_round_file_last`); const last_round_file = response.split("=")[1].trim().toString(); if (last_round_file.includes('.txt')) { - // rcon.rcons[server_id].execute(`mp_backup_restore_load_file ${last_round_file}`); - // rcon.rcons[server_id].execute('mp_pause_match'); await rcon.execute_command(server_id, `mp_backup_restore_load_file ${last_round_file}`); await rcon.execute_command(server_id, `mp_pause_match`); - //return res.status(200).json({ message: `Latest Round Restored! (${last_round_file})` }); + return res.status(200).json({ message: `Latest Round Restored! (${last_round_file})` }); } else { - //return res.status(200).json({ message: 'No latest backup found!' }); + return res.status(200).json({ message: 'No latest backup found!' }); } } catch (error) { @@ -191,9 +181,8 @@ router.post('/api/restore-latest-backup', is_authenticated, async (req, res) => router.post('/api/pause', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // rcon.rcons[server_id].execute('mp_pause_match'); const response = await rcon.execute_command(server_id, 'mp_pause_match'); - //return res.status(200).json({ message: 'Game paused' }); + return res.status(200).json({ message: 'Game paused' }); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } @@ -203,9 +192,8 @@ router.post('/api/pause', is_authenticated, async (req, res) => { router.post('/api/unpause', is_authenticated, async (req, res) => { try { const server_id = req.body.server_id; - // rcon.rcons[server_id].execute('mp_unpause_match'); const response = await rcon.execute_command(server_id, 'mp_unpause_match'); - //return res.status(200).json({ message: 'Game unpaused' }); + return res.status(200).json({ message: 'Game unpaused' }); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } @@ -219,10 +207,10 @@ router.post('/api/rcon', is_authenticated, async (req, res) => { const response = await rcon.execute_command(server_id, command); if (response == 200) { - //return res.status(200).json({ message: 'Command sent!' }); + return res.status(200).json({ message: 'Command sent!' }); } - //return res.status(200).json({ message: 'Command sent! Response received:\n' + response.toString() }); + return res.status(200).json({ message: 'Command sent! Response received:\n' + response.toString() }); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } @@ -234,7 +222,7 @@ router.post('/api/say-admin', is_authenticated, async (req, res) => { const message = req.body.message; const message_to_send = "say " + message; await rcon.execute_command(server_id, message_to_send); - //return res.status(200).json({ message: 'Message sent!' }); + return res.status(200).json({ message: 'Message sent!' }); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } @@ -310,7 +298,6 @@ async function execute_cfg_on_server(server_id, cfg_path) { try { if (item < exported_lines.length) { console.log("Executing on server:", exported_lines[item]); - // rcon.rcons[server_id].execute(exported_lines[item]); await rcon.execute_command(server_id, exported_lines[item]); // Wait for 100ms before moving to the next iteration diff --git a/views/manage.ejs b/views/manage.ejs index 201ebb8..3e9fea1 100644 --- a/views/manage.ejs +++ b/views/manage.ejs @@ -94,7 +94,16 @@ - +
+ + +
-
- - -
-