├── .gitattributes ├── README.md └── Upload.cmd /.gitattributes: -------------------------------------------------------------------------------- 1 | *.cmd text eol=crlf 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Garry's Mod Easy Addon Uploader 2 | 3 | ## Instructions 4 | 5 | 1. Create *the folder of your addon* in *garrysmod\addons* and place your files in it. If your addon is already there then ignore this step. 6 | 7 | 2. Create a thumbnail for your addon: picture of 512x512 pixels. 8 | Save it as a JPEG image in *the folder of your addon* and name it the same as *the folder of your addon*. 9 | Choose quality 100 if possible. 10 | The [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling) must be **4:2:0** (for instance GIMP and Photoshop can use 4:2:2 or 4:4:4). 11 | 12 | 3. Place *Upload.cmd* in *the folder of your addon*. 13 | 14 | 4. Run *Upload.cmd* and follow instructions **until the window closes automatically**. 15 | 16 | When you want to update, just run *Upload.cmd* and enter the reason (with only US-ASCII characters). Your addon must contain the files *addon.json* and *workshop_id.cmd*. 17 | 18 | If you do not want to place the addon in your *garrysmod\addons* folder then you need to make sure that the *GarrysMod* path is correct by editing *Upload.cmd*. 19 | 20 | ## Common issues 21 | 22 | * *GMad* tells me that I have files that are not allowed by whitelist! 23 | 1. Remove useless files or blacklist them with the `"ignore"` section of your *addon.json*. 24 | 2. **Models** must be placed somewhere in the *models* folder. 25 | 3. **Sounds** must be placed somewhere in the *sound* folder. 26 | 4. **Materials, textures and PNG images** must be placed somewhere in the *materials* folder. 27 | 5. **Lua scripts** must be placed somewhere in the *lua* folder. 28 | 6. **Vehicle scripts** must be placed in the *scripts\vehicles* folder. 29 | 7. **Fonts** must be placed in the *resource\fonts* folder. 30 | 8. etc. 31 | * I accidentally closed the window when it asked for the UID, I removed the *workshop_id.cmd*, or I mistyped the UID! 32 | 1. Create or edit the file *workshop_id.cmd* 33 | 2. Place this code inside: `set WorkshopId=000000000` 34 | 3. Replace `000000000` by the UID of your addon. You can see it in the URL of your Workshop addon. 35 | * I made a mistake in my *addon.json*, how do I re-generate it? 36 | 1. Remove *addon.json*. You will have to enter information again. 37 | * *GMad* tells me that I have uppercase characters, spaces or whatever forbidden in filenames! 38 | 1. Simply rename everything including extensions to make them: lowercase, no accents, no spaces. 39 | 2. If you rename models, you really should modify your QC script and re-generate the model (bug with *Entity:GetModel()* clientside). 40 | 3. If you rename textures, do not forget to modify VMTs that need them. 41 | 4. Of course, do not forget to update your scripts in order to match with the new filenames. 42 | * *GMPublish* returns an error that I do not understand after uploading! 43 | 1. You probably put accents / special characters in the title of your addon. The Windows console does not use the UTF-8 character set, so it generates illegal UTF-8 sequences. Please remove accents or edit your *addon.json* as UTF-8. 44 | 2. The change note must not contain accents either for the same reason. Please do not type accents. 45 | 46 | ## Links 47 | 48 | * [GMad usage](https://www.facepunch.com/showthread.php?t=1242185) 49 | * [GMPublish usage](https://www.facepunch.com/showthread.php?t=1244179) 50 | -------------------------------------------------------------------------------- /Upload.cmd: -------------------------------------------------------------------------------- 1 | :: Place this file in your addon folder and run it. 2 | :: The "addon.json" is generated automatically. 3 | :: After uploading, the UID must be entered. It is stored in "workshop_id.cmd" 4 | :: Do not remove the generated "workshop_id.cmd"! 5 | :: If the GarrysMod path is incorrect then change it! 6 | :: By Mohamed RACHID. 7 | 8 | @echo off 9 | 10 | :: Configuration: 11 | set GarrysMod=C:\Program Files (x86)\Steam\steamapps\common\GarrysMod 12 | 13 | :: Note: a '+' is prepended for replacements in variables to avoid empty variables, which do not handle replacements. 14 | 15 | :: Find path from addon path if GarrysMod path is missing. 16 | if not exist "%GarrysMod%\bin\gmad.exe" goto fixpath 17 | if not exist "%GarrysMod%\bin\gmpublish.exe" goto fixpath 18 | goto name 19 | :fixpath 20 | set GarrysMod=%CD%\..\..\.. 21 | if not exist "%GarrysMod%\bin\gmad.exe" goto nobin 22 | if not exist "%GarrysMod%\bin\gmpublish.exe" goto nobin 23 | goto name 24 | 25 | :: Get the addon name: 26 | :name 27 | set i=0 28 | :nameloop 29 | echo set name=%%CD:~-%i%%%> Upload.temp.cmd 30 | call Upload.temp.cmd 31 | set /A i=i+1 32 | :: loop until first found backslash 33 | if not "%name:~0,1%"=="\" goto nameloop 34 | del Upload.temp.cmd 35 | set name=%name:~1% 36 | 37 | :: Create addon.json if missing 38 | :json 39 | cls 40 | if exist "addon.json" goto gma 41 | echo. 42 | set /P title=Please enter the title of the addon (no accents): 43 | set title=+%title% 44 | set title=%title:"='% 45 | set title=%title:~1% 46 | echo. 47 | echo List of allowed types: 48 | echo - effects 49 | echo - gamemode 50 | echo - map 51 | echo - model 52 | echo - npc 53 | echo - ServerContent 54 | echo - tool 55 | echo - vehicle 56 | echo - weapon 57 | set /P type=Please enter the type of the addon (case-sensitive): 58 | set type=+%type% 59 | set type=%type:"=% 60 | set type=%type:~1% 61 | echo. 62 | echo List of allowed tags: 63 | echo - build 64 | echo - cartoon 65 | echo - comic 66 | echo - fun 67 | echo - movie 68 | echo - realism 69 | echo - roleplay 70 | echo - scenic 71 | echo - water 72 | set /P tag1=Please enter the tag 1 of 2 of the addon (optional, case-sensitive): 73 | set tag1=+%tag1% 74 | set tag1=%tag1:"=% 75 | set tag1=%tag1:~1% 76 | set tag2= 77 | if "%tag1%"=="" goto jsontagprocess 78 | set /P tag2=Please enter the tag 2 of 2 of the addon (optional, case-sensitive): 79 | set tag2=+%tag2% 80 | set tag2=%tag2:"=% 81 | set tag2=%tag2:~1% 82 | :jsontagprocess 83 | if "%tag1%"=="" goto jsontag0 84 | if "%tag2%"=="" goto jsontag1 85 | goto jsontag2 86 | :jsontag0 87 | set tags= 88 | goto jsontagok 89 | :jsontag1 90 | set tags="%tag1%" 91 | goto jsontagok 92 | :jsontag2 93 | set tags="%tag1%","%tag2%" 94 | goto jsontagok 95 | :jsontagok 96 | echo {> addon.json 97 | echo "title" : "%title%",>> addon.json 98 | echo "type" : "%type%",>> addon.json 99 | echo "tags" : [%tags%],>> addon.json 100 | echo "ignore":>> addon.json 101 | echo [>> addon.json 102 | echo "*.cmd",>> addon.json 103 | echo "*.ini",>> addon.json 104 | echo "*.lnk",>> addon.json 105 | echo "*.url",>> addon.json 106 | echo "%name%.jpg",>> addon.json 107 | echo "%name%.png">> addon.json 108 | echo ]>> addon.json 109 | echo }>> addon.json 110 | cls 111 | type addon.json 112 | echo. 113 | echo If you need to modify this generated addon.json, close this window now. 114 | pause 115 | 116 | :: Create GMA archive 117 | :gma 118 | set target=%GarrysMod%\%name%.gma 119 | del "%target%"> NUL 2>&1 120 | echo. 121 | "%GarrysMod%\bin\gmad.exe" create -out "%target%" -folder "%CD%\\" 122 | if not exist "%target%" goto nogma 123 | echo. 124 | echo If no problem happened, press any key to continue... 125 | pause> NUL 126 | 127 | :: Upload GMA 128 | cls 129 | set thumbnail= 130 | if exist "%name%.jpg" set thumbnail=-icon "%CD%\%name%.jpg" 131 | set WorkshopId= 132 | call workshop_id.cmd> NUL 2>&1 133 | if "%WorkshopId%"=="" goto new 134 | goto update 135 | :new 136 | if not exist "%name%.jpg" goto noicon 137 | "%GarrysMod%\bin\gmpublish.exe" create -addon "%target%" %thumbnail% 138 | if errorlevel 1 goto uperror 139 | echo. 140 | set /P WorkshopId=Enter the displayed UID: 141 | echo set WorkshopId=%WorkshopId%> workshop_id.cmd 142 | goto finished 143 | :update 144 | echo. 145 | echo What have you changed? (single line) 146 | set /P changes= 147 | set changes=+%changes% 148 | set changes=%changes:"='% 149 | set changes=%changes:~1% 150 | "%GarrysMod%\bin\gmpublish.exe" update -addon "%target%" %thumbnail% -id "%WorkshopId%" -changes "%changes%" 151 | if errorlevel 1 goto uperror 152 | goto finished 153 | :finished 154 | goto end 155 | 156 | :: Error: Missing binaries! 157 | :nobin 158 | cls 159 | echo. 160 | echo gma.exe or gmpublish.exe could not be located. 161 | echo Please edit this file and fix the path to Garry's Mod. 162 | goto end 163 | 164 | :: Error: GMA not created! 165 | :nogma 166 | echo. 167 | echo The GMA file could not be created because of an error. 168 | goto end 169 | 170 | :: Error: Icon missing in new GMA! 171 | :noicon 172 | echo. 173 | echo The thumbnail file is missing. It is required for new addons. 174 | echo Please make a picture of 512x512 pixels. 175 | echo Save it in the folder of the addon as JPEG and name it: 176 | echo %name%.jpg 177 | echo Choose quality 100 if you can. 178 | goto end 179 | 180 | :: Error: GMA not uploaded! 181 | :uperror 182 | echo. 183 | echo The addon could not be uploaded. 184 | goto end 185 | 186 | :: End 187 | :end 188 | del "%target%"> NUL 2>&1 189 | pause 190 | 191 | --------------------------------------------------------------------------------