Last active
June 23, 2023 11:59
-
-
Save nfitzen/102ba0cd3078ec043317289c0ef62883 to your computer and use it in GitHub Desktop.
Downloads Counter-Strike: Source assets for Garry's Mod from Steam's official servers, for free (gratis). Just place in an empty directory and double click.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: SPDX-License-Identifier: MIT | |
:: MIT License | |
:: | |
:: Copyright (C) 2021-2022 nfitzen <https://github.com/nfitzen> | |
:: | |
:: Permission is hereby granted, free of charge, to any person obtaining a copy | |
:: of this software and associated documentation files (the "Software"), to deal | |
:: in the Software without restriction, including without limitation the rights | |
:: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
:: copies of the Software, and to permit persons to whom the Software is | |
:: furnished to do so, subject to the following conditions: | |
:: | |
:: The above copyright notice and this permission notice | |
:: (including the next paragraph) shall be included in all copies or substantial | |
:: portions of the Software. | |
:: | |
:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
:: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
:: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
:: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
:: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
:: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
:: SOFTWARE. | |
:: If viewing this offline, you can find a (potentially updated) copy of this | |
:: file at <https://gist.github.com/nfitzen/102ba0cd3078ec043317289c0ef62883>. | |
:: Downloads Counter-Strike: Source content to Gmod from Steam's servers. | |
:: Place this executable in a clean directory. (It's gonna download a bunch of | |
:: junk.) If you've already run it, you may keep the files there. It'll update | |
:: the assets without needing to fully download the CS:S server again. | |
:: Takes 2 optional command line arguments. | |
:: 1. The Garry's Mod folder. | |
:: 2. Whether to use the temp directory (Y/N). (Default Y, but ONLY IF the | |
:: first command line argument is specified.) | |
:: Because CS:S's vpk.exe is glitchy, Gmod's is used. | |
:: Ergo, you can't just extract it to a random directory. | |
@echo off | |
:: Initial setup and variables. Change these if something's wrong. | |
set gmod=%ProgramFiles(x86)%\Steam\steamapps\common\GarrysMod | |
set using_temp=0 | |
if "%~1" NEQ "" ( | |
echo Using the Gmod folder specified. | |
set "gmod=%~1" | |
if not "%~2" == "Y" ( | |
echo Because you may have dragged the Gmod folder onto the script, we'll use your temp directory to download and process files. | |
cd /D %TEMP% | |
@rem adding random numbers at the end for uniqueness | |
rd /Q /S DL_CSS_18257123570 | |
mkdir DL_CSS_18257123570 | |
cd DL_CSS_18257123570 | |
set using_temp=1 | |
) | |
goto :gmod_path_loop_check | |
) | |
:: This probably works. We'll see. | |
if exist "%gmod%" ( | |
echo Automatically detected your Gmod folder at the default location. | |
goto end_gmod_path_loop | |
) | |
:gmod_path_loop | |
set /p "gmod=Path to your Gmod folder (you can drag and drop the folder in this window): " | |
:gmod_path_loop_check | |
if not exist "%gmod%\hl2.exe" ( | |
echo Game binary doesn't exist. Make sure your folder's correct! | |
goto gmod_path_loop | |
) | |
:end_gmod_path_loop | |
echo The Gmod folder selected is: %gmod%. | |
choice /C YNP /M "Do you wish to proceed? (Y:proceed, N:exit, P:change path)" | |
if %ERRORLEVEL%==2 exit /B 2 | |
if %ERRORLEVEL%==3 goto :gmod_path_loop | |
:: normal, automated stuff. | |
set vpk=%gmod%\bin\vpk.exe | |
if not exist "%vpk%" ( | |
echo Gmod vpk.exe doesn't exist. Check your directory and consider verifying your game files/re-downloading the game. | |
pause | |
exit /B 1 | |
) | |
mkdir steamcmd | |
if exist steamcmd.exe ( | |
move steamcmd.exe steamcmd\steamcmd.exe | |
) | |
if not exist steamcmd\steamcmd.exe ( @rem thanks, batch. | |
call :download_7zip | |
) | |
if not exist steamcmd\steamcmd.exe ( | |
if not exist steamcmd.zip ( | |
powershell -Command "Invoke-WebRequest https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip -OutFile steamcmd.zip" | |
) | |
%_7zip% e steamcmd.zip steamcmd.exe | |
move steamcmd.exe steamcmd\steamcmd.exe | |
) | |
steamcmd\steamcmd.exe +force_install_dir ..\css +login anonymous +app_update 232330 -validate +quit | |
echo CSS downloaded or verified. | |
echo If there was no further download process (i.e., if Steam just | |
echo verified the game), then you can quit now to save time. | |
choice /M "Do you wish to proceed?" | |
if not %ERRORLEVEL%==1 exit /B 1 | |
rd /Q /S vpks | |
mkdir vpks | |
copy css\cstrike\cstrike_pak_*.vpk vpks\ | |
cd vpks | |
"%vpk%" cstrike_pak_dir.vpk | |
cd cstrike_pak_dir | |
set csscontent=%gmod%\garrysmod\addons\CSSContent | |
rd /Q /S "%csscontent%" | |
mkdir "%csscontent%" | |
robocopy maps "%csscontent%\maps" /E /NFL /NDL | |
robocopy materials "%csscontent%\materials" /E /NFL /NDL | |
robocopy models "%csscontent%\models" /E /NFL /NDL | |
robocopy particles "%csscontent%\particles" /E /NFL /NDL | |
robocopy resource "%csscontent%\resource" /E /NFL /NDL | |
robocopy sound "%csscontent%\sound" /E /NFL /NDL | |
cd ..\..\css\cstrike | |
robocopy maps "%csscontent%\maps" /E /NFL /NDL | |
:: cleanup temp directory if applicable | |
if %using_temp%==1 ( | |
cd /D %TEMP% | |
rd /Q /S .\DL_CSS_18257123570 | |
) | |
pause | |
exit /B 0 | |
:download_7zip | |
where /q 7z | |
if errorlevel 1 ( | |
if not exist 7za.exe ( | |
powershell -Command "Invoke-WebRequest https://www.7-zip.org/a/7zr.exe -OutFile 7zr.exe" | |
powershell -Command "Invoke-WebRequest https://www.7-zip.org/a/7z1900-extra.7z -OutFile 7zex.7z" | |
7zr.exe e 7zex.7z 7za.exe | |
del 7zr.exe 7zex.7z | |
) | |
set _7zip=.\7za.exe | |
) else set _7zip=7z | |
exit /B 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment