conditionnal warmup for rounds

This commit is contained in:
shoopea 2024-10-29 20:33:05 +01:00
parent 3c1c2d18e6
commit a0ae297bf6

View File

@ -31,10 +31,10 @@ router.post('/api/setup-game', is_authenticated, async (req, res) => {
await rcon.execute_command(server_id, `game_mode 1`);
execute_cfg_on_server(server_id, './cfg/live_competitive_24.cfg');
} else if (game == "3") {
await rcon.execute_command(server_id, `game_mode 1`);
await rcon.execute_command(server_id, `game_mode 0`);
execute_cfg_on_server(server_id, './cfg/live_casual_16.cfg');
} else if (game == "4") {
await rcon.execute_command(server_id, `game_mode 1`);
await rcon.execute_command(server_id, `game_mode 0`);
execute_cfg_on_server(server_id, './cfg/live_casual_24.cfg');
} else if (game == "5") {
await rcon.execute_command(server_id, `game_mode 2`);
@ -44,9 +44,15 @@ router.post('/api/setup-game', is_authenticated, async (req, res) => {
await rcon.execute_command(server_id, `changelevel ${map}`);
// Adding 1 second delay in executing warmup.cfg to make it effective after map has been changed.
if (game == "1" || game == "3" || game == "5") {
setTimeout(() => {
execute_cfg_on_server(server_id, './cfg/warmup.cfg');
execute_cfg_on_server(server_id, './cfg/warmup_16.cfg');
}, 1000)
} else if (game == "2" || game == "4") {
setTimeout(() => {
execute_cfg_on_server(server_id, './cfg/warmup_24.cfg');
}, 1000)
}
return res.status(200).json({ message: 'Game Created!' });
} catch (error) {