NOTICE: Both scripts will rotate missions without checking state of previous game. That means on server crash next mission in list will be started from scratch. Use at your own risk.
Originally posted by Uro at https://discord.com/channels/105462288051380224/976119935875026964/979127368973168690.
I wrote a PowerShell script that server admins using Windows can implement to programmatically change the server.json config file to switch missions/implement a mission rotation.
You need to run this PowerShell script before your server launches, so if you have things setup to restart the server when the mission ends and the server dies then execute this script prior to it restarting the server executable - a caveat to doing it this way is that it will always switch missions when your server restarts, even if it crashed unintentionally. Linux server operators could easily adapt this to a shell script to have similar functionality. File is documented internally, MIT licenced. https://gitlab.com/Uro1/scripts/-/blob/main/ArmaReforgerServer/serverJson_switch_mission.ps1
Originally posted by Marko at https://discord.com/channels/105462288051380224/976119935875026964/979152350197452850.
Same thing but for linux, without fancy JSON processing cause ain't nobody got time for that. WARNING: Use at Your Own Risk
One downside is, that if user doesn't check if server crashed, it will load new campaign none the less
#!/bin/bash
# Path to config goes ere'
ConfFilePath=.config/ArmaReforgerServer/config.json
# Array of scenarioId to rotate
ScenarioArray=(
'{FDE33AFE2ED7875B}Missions/23_Campaign_Montignac.conf'
'{C700DB41F0C546E1}Missions/23_Campaign_NorthCentral.conf'
'{1AEE808E7689FE54}Missions/23_Campaign_NWCoast.conf'
'{6C3A09ACE0AD3721}Missions/23_Campaign_PinewoodLake.conf'
'{D0BCF58CE5411856}Missions/23_Campaign_Ridge.conf'
'{28802845ADA64D52}Missions/23_Campaign_SWCoast.conf'
'{0FC71901A21374FA}Missions/23_Campaign_Tower.conf'
'{28911C35F7B55579}Missions/23_Campaign_WestSmall.conf'
)
# Read current scenarioId from conf
CurScenario=$(cat $ConfFilePath | grep 'scenarioId' | cut -d "\"" -f4)
# Set fallback just in case
NextScenario=CurScenario
echo "Current scenario: $CurScenario"
ScenarioArrayCount=$((${#ScenarioArray[@]}-1));
for i in ${!ScenarioArray[@]};
do
if [ "${ScenarioArray[$i]}" = "$CurScenario" ]; then
# Find current scenarioId in array
break
fi
done
# Rotate if last
if (($i >= ScenarioArrayCount)); then
i=0
else
((i=i+1))
fi
NextScenario="${ScenarioArray[$i]}"
# Replace id in file
sed -i "s%$CurScenario%$NextScenario%" $ConfFilePath
echo "Next scenario: $NextScenario"