1. Good day, everyone! Me again!

    I just wrote a script for my server, which autorestarts thanks to GUIAnnouncements. Sadly, I needed (or wanted) a plugin/script that RESET the whole server after a time of x days... and plugins seem to be incapable of doing so.

    So now here I release my script for the Autoupdate+Autoreset. I am a beginner when it comes to batch-scripting and everything else), so please be merciful and tell me, if you find any errors or mistakes. Constructive Critique yäy! <3

    I tried the script and it seemed to work as intended.

    Requirements:
    - SteamCMD
    - GUIAnnouncements or some other plugin that supports scheduled restarts.


    Version 1.00 (19.08.2016):
    Code:
    ::Sets echoes to off. Good if you are in an empty room or a large mountainrange...
    @echo off
    ::I honestly do not know what "cls" does:
    cls
    :start
    echo Starting server...::VARIABLES
        ::as "resetcycle" set the amount of days you want for a wipe. Default is 30 days.
        SET /A resetcycle=30
        ::as "restartcycle" set the amount of hours the server runs before it restarts (could be solved better)
        SET /A restartcycle=6
        ::unless you are australian (days have a different amount of hours there), you should not change this.
        SET /A hoursperday=24
        ::had to set this +1, because the batch writes two lines on creation, I call it feature.
        SET /A maxlines=(%hoursperday% / %restartcycle%) * %resetcycle%+1
        ::uncomment the line below and comment the line above for script-testing.
        ::SET /A maxlines=5
        SET filename=counter.txt
        SET scriptseedfile=scriptseed.txt  
        SET /A startnumber=1
      
    ::STEAMCMD-SETTINGS
        ::Set to 1 if you have SteamCMD installed!
        SET steamcmd = 0
        ::PATH of your Rustserver-installation:
        SET rustinstallpath = "C:\Server\rust"
        ::Path for Autoupdate! (Default is a folder in your rust-directory!)
        SET steamcmdpath="SteamCMD\steamcmd.exe"
      
    ::VARIABLES FOR THE SERVER!!! CHANGE ACCORDINGLY!!!
        SET scriptwindowname="RustServer"
        SET serverexename=RustDedicated.exe
        SET /A scriptserverport=28015
        SET /A scriptrconport=28016
        ::You should change this.
        SET scriptrconpwd="chooseasavepassword!"
        ::The headerimage of your rustserver. "512x256 .jpg or .png"
        SET scriptheadimg="http://echstreme.de/gfx/echstreme-rustserverheaderimg.png"
        SET /A scriptmaxplayers=42
        ::Change this to something not trolly. You might want to start with the region+lang for your server, examply: "[EU/UK][ENG]servername.org RUST, noobfriendly, adult only. YEAH BEER!"
        SET scripthostname="I was not smart enough to change my servertitle"
        ::There will be a number on the end of scriptserverident that raises by 1 each reset!
        SET scriptserverident=server
        ::This you usually do not want to change without research.
        SET scriptmap="Procedural Map"
        ::Set between 2000 and 6000!
        SET /A scriptworldsize=2000
        ::How often your server saves (in seconds)
        SET /A scriptsaveinterval=300
        ::Some decayscale of buildings, I guess. 0 means off. You may want to google "decay.scale RUST" to know what to set here.
        SET scriptdecayscale=0
        ::Your serverdescription. Change it.
        SET scriptdescription="Serverdescription here! Until then: this server is reset by a script that was brought to you by echstreme.designs. :P"
        ::The url to your serverwebsite. If you leave this like it is, people will be linked to my facebook page.
        SET scripturl="https://www.facebook.com/echstreme.designs"
      ::Check for existing seedfile and, if inexisting, create it.
        IF NOT Exist %scriptseedfile% SET /A scriptseed=%RANDOM%*114
        IF NOT Exist %scriptseedfile% (echo %scriptseed%)>%scriptseedfile%
      
      
    ::create file if not exists and writes the startnumber into the file. TWICE. :(
        IF NOT Exist %filename% (echo %startnumber%)>%filename%
    ::check file for last line and set lastnumber
        for /f "delims==" %%a in (%filename%) do set /A lastnumber=%%a
    ::check amount of lines in file.
        for /f %%C in ('Find /V /C "" ^< %filename%') do set /A linecount=%%C
    ::check amount of lines exceeding the maximum.
        set /A linecheck = %linecount% %% %maxlines%    if %linecheck% == 0 (
            GOTO RESET
        ) ELSE (
            GOTO NORESET
        )
      
        :RESET
    ::raises the lastnumber by 1.
        SET /A lastnumber=%lastnumber%+1
    ::deletes the file
        del %filename%
    ::writes the lastnumber to the file. TWICE. :(
        (echo %lastnumber%)>%filename%
    ::New Seed written to the seedfile.
        set /A scriptseed=%RANDOM%*114
        (echo %scriptseed%)>%scriptseedfile%
        GOTO SERVERSTART  
        :NORESET
    ::writes the lastnumber to the file. Once! (luckily...)
        (echo %lastnumber%)>>%filename%
    ::check seedfile for seed
        for /f "delims==" %%a in (%scriptseedfile%) do set /A scriptseed=%%a
        GOTO SERVERSTART
      
      
        :SERVERSTART
    ::SERVERUPDATE! NEEDS SteamCMD installed!!!
        if steamcmd == 1 (
            start /wait "SteamCMD" %steamcmdpath% +login anonymous +force_install_dir %rustinstallpath% +app_update 258550 +quit
        ):: ATTENTION!!! THIS IS MIGHT HAVE THINGS INSIDE THAT YOU WANT TO CHANGE!
        start /wait %scriptwindowname% %serverexename% -batchmode -server.port %scriptserverport% +server.headerimage: %scriptheadimg% +rcon.port %scriptrconport% +rcon.password %scriptrconpwd% +server.maxplayers %scriptmaxplayers% +server.hostname %scripthostname% -server.identity "%scriptserverident%%lastnumber%" +server.level %scriptmap% -server.seed %scriptseed% -server.worldsize %scriptworldsize% +server.saveinterval %scriptsaveinterval% +server.netlog 1 +spawn.max_rate 1 +spawn.max_density 1 +autoupdate +god 1 +decay.scale %scriptdecayscale% +server.description %scriptdescription% +server.url %scripturl% +chat.serverlog 1 -server.netlog 1    echo.
        echo Restarting server...
        echo.
        goto start
    BY DOWNLOADING THIS SCRIPT YOU AGREE THAT YOU KNOW WHAT YOU DO (because I do not)! IF ANY HARM (physically and psychologically) COMES TO YOU, YOUR FAMILY, YOUR PET, YOUR DATA, YOUR COUNTRY, YOUR HARD- AND/OR SOFTWARE IT IS YOUR OWN FAULT!

    Enjoy! Solbless! Godspeed!

    --Glɑumy - Niemɑnd
    (admin of echstreme.designs)
     

    Attached Files: