@echo off
echo BRPVP SERVER AND HC - ALTIS!

:begin

    tasklist | findstr /i "arma3server_x64_BRPVP.exe" > nul
    if "%ERRORLEVEL%"=="1" goto :restart

    echo [ALTIS] SERVER IS ON!
    echo [ALTIS] WAITING FOR SERVER TO SHUTDOWN...

    goto :serveron


:restart

    echo [ALTIS] SERVER NOT FOUND!

    tasklist | findstr /i "arma3server_x64_BRPVPHC.exe" > nul
    if "%ERRORLEVEL%"=="0" goto :killhc

    :killhc

        echo [ALTIS] STOPPING HC PROCESS
        taskkill /F /IM arma3server_x64_BRPVPHC.exe > nul
        timeout 5 > nul

    echo [ALTIS] STARTING SERVER AND HC!

    start /D "C:\Steam\ArmA3\a3master" arma3server_x64_BRPVP.exe -port=2402 "-config=C:\Steam\ArmA3\a3master\Servers\_68b9e4707d2e4fa286f6b6e98141ebcc\server_config.cfg" "-cfg=C:\Steam\ArmA3\a3master\Servers\_68b9e4707d2e4fa286f6b6e98141ebcc\server_basic.cfg" "-profiles=C:\Steam\ArmA3\a3master\Servers\_68b9e4707d2e4fa286f6b6e98141ebcc" -name=_68b9e4707d2e4fa286f6b6e98141ebcc "-serverMod=@BRPVP_server;@extDB3;" -enableHT -autoInit

    timeout 3 > nul

    start /D "C:\Steam\ArmA3\a3master" arma3server_x64_BRPVPHC.exe -client -connect=127.0.0.1 -password= "-profiles=C:\Steam\ArmA3\a3master\Servers\_68b9e4707d2e4fa286f6b6e98141ebcc_hc1" -nosound -port=2402 -enableHT

    timeout 60 > nul

    goto :begin

:serveron

    echo [ALTIS] WAITING FOR SERVER TO SHUTDOWN...
    
    timeout 60 > nul
    
    goto :begin