Skip to content

Instantly share code, notes, and snippets.

@TheGamerzs
Created April 6, 2024 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheGamerzs/d31c7b76b4b26091a8defa4bd3eaab10 to your computer and use it in GitHub Desktop.
Save TheGamerzs/d31c7b76b4b26091a8defa4bd3eaab10 to your computer and use it in GitHub Desktop.
Update fxserver automatically to latest - Windows
@echo off
setlocal enabledelayedexpansion
echo "Updating server..."
:: Delete the old server folder
rmdir /s /q server
:: Download the new server, from https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/ get zip from href where `<a class="panel-block is-active"` using its `href` attribute, only first result
curl -s https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/ | findstr /i /c:"<a class=\"panel-block is-active\"" > temp.txt
set line=1
for /f "delims=" %%L in (temp.txt) do (
set "line[!line!]=%%L"
set /a line+=1
)
set href=!line[1]:*href=!
set href=!href:~4,-26!
del temp.txt
:: Download the zip file
curl -o server.7z https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/%href%
:: Unzip the new server, in `server` folder
7z x server.7z -oserver
:: Delete the zip file
del server.7z
:: href contains the new version number, set it to a variable, number starts at 0, ends when it finds a `-`
:: Loop through the string, if it finds a `-` then stop
set buildNumber=0
set href=%href:-=+%
for /f "delims=+" %%a in ("%href%") do (
set buildNumber=%%a
goto :break
)
:break
:: Add the new version number to log.txt, with the date
echo %date% %time% %buildNumber% >> update_log.txt
:: Done
echo "Server updated! (%buildNumber%)"
pause >nul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment