# List all maps availlable on base game
Map='KF-Airship'
Map+=('KF-AshwoodAsylum')
Map+=('KF-Biolapse')
Map+=('KF-BioticsLab')
Map+=('KF-BlackForest')
Map+=('KF-BurningParis')
Map+=('KF-Catacombs')
Map+=('KF-ContainmentStation')
Map+=('KF-Desolation')
Map+=('KF-DieSector')
Map+=('KF-Dystopia2029')
Map+=('KF-Moonbase')
Map+=('KF-Elysium')
Map+=('KF-EvacuationPoint')
Map+=('KF-Farmhouse')
Map+=('KF-HellmarkStation')
Map+=('KF-HostileGrounds')
Map+=('KF-InfernalRealm')
Map+=('KF-KrampusLair')
Map+=('KF-Lockdown')
Map+=('KF-MonsterBall')
Map+=('KF-Nightmare')
Map+=('KF-Nuked')
Map+=('KF-Outpost')
Map+=('KF-PowerCore_Holdout')
Map+=('KF-Prison')
Map+=('KF-Sanitarium')
Map+=('KF-SantasWorkshop')
Map+=('KF-ShoppingSpree')
Map+=('KF-Spillway')
Map+=('KF-SteamFortress')
Map+=('KF-TheDescent')
Map+=('KF-TragicKingdom')
Map+=('KF-VolterManor')
Map+=('KF-ZedLanding')
Map+=('KF-Netherhold')
Map+=('KF-CarillonHamlet')
Map+=('KF-Rig')
Map+=('KF-BarmwichTown')
Map+=('KF-Crash')
Map+=('KF-Subduction')
Map+=('KF-CastleVolter')
# Regarde pour chaque ligne bPlayableIn :
for i in "${Map[@]}"
do
if [[ $GameMode =~ "KFGameInfo_WeeklySurvival" ]]; then
playable=`sed -n "/\[${i}/{n;n;n;n;n;p}" ~/Servers/KF2/$DirectoryServer/KFGame/Config/LinuxServer-KFGame.ini` # On cherche la ligne du mode Weekly
elif [[ $GameMode =~ "KFGameInfo_VersusSurvival" ]]; then
playable=`sed -n "/\[${i}/{n;n;n;n;n;n;p}" ~/Servers/KF2/$DirectoryServer/KFGame/Config/LinuxServer-KFGame.ini` # On cherche la ligne du mode VS
elif [[ $GameMode =~ "KFGameInfo_Endless" || $GameMode =~ "ZedternalReborn" ]]; then
playable=`sed -n "/\[${i}/{n;n;n;n;n;n;n;p}" ~/Servers/KF2/$DirectoryServer/KFGame/Config/LinuxServer-KFGame.ini` # On cherche la ligne du mode endless
elif [[ $GameMode =~ "KFGameInfo_Objective" ]]; then
playable=`sed -n "/\[${i}/{n;n;n;n;n;n;n;n;p}" ~/Servers/KF2/$DirectoryServer/KFGame/Config/LinuxServer-KFGame.ini` # On cherche la ligne du mode Objectif
else
# Mode par défaut, survie
playable=`sed -n "/\[${i}/{n;n;n;n;p}" ~/Servers/KF2/$DirectoryServer/KFGame/Config/LinuxServer-KFGame.ini` # On cherche la ligne du mode survie
fi
# Si la carte est jouable, on l'ajoute a une nouvelle liste
if [[ $playable =~ "True" ]]; then
listeMap+=(${i})
fi
i=i+1
done
# Lancement serveur
cd /home/steam/Servers/KF2/$DirectoryServer/Binaries/Win64/
nohup ./KFGameSteamServer.bin.x86_64 ${listeMap[ $RANDOM % ${#listeMap[@]} ]}$GameMode$Mutator?Difficulty=$Difficulty?GameLength=$GameLength -Port=$Port -Queryport=$Queryport -WebAdminPort=$WebAdminPort -ConfigSubDir=$ConfigSubDir >> ~/logs/$ConfigSubDir.log &