Setup mod on Steam: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
Line 1: Line 1:
{{cleanup|Article could be improved to include instructions for Mac/Linux}}
{{cleanup|Article could be improved to include instructions for Mac/Linux}}
To make a Source [[mod]] appear in your Steam library, its [[Game Directory]] (the one that has [[gameinfo.txt]] inside) must exist as a folder inside <code>steam/steamapps/sourcemods/</code>. Its name, the assets it mounts, and the Source SDK branch it uses is controlled by <code>gameinfo.txt</code>. When the player clicks the '''play''' button, Steam will launch the appropriate [[Source SDK Base 2013| Source SDK Base]], which will attempt to load the mod's <code>client.dll</code> and <code>server.dll</code> from the <code>/bin</code> or <code>/bin/x64/</code> folder.


You can use {{Wikipedia|Symbolic link|Symlinks}} to help make the mod development process more convenient.
{{Note|If you want to ''distribute'' the mod on Steam (i.e. the mod has its own Steam page, players download the mod through Steam instead of a 3rd party site), see [https://partner.steamgames.com/doc/sdk/uploading/distributing_source_engine this Steamworks article].}}
{{Tip|Changes to your <code>sourcemods</code> directory only appear after you restart Steam. Restart Steam by clicking the small 'Steam' button at the top-left of the Steam window, and then clicking 'Exit'. After it closes, open Steam again.}}
=Mod files=
=Mod files=
In order to launch your mod, the necessary files need to be created in your <code>steamapps</code> folder. [[Source SDK 2013]] provides some base files for you in the <code>game/</code> directory. This folder contains all the necessary assets, binaries and scripts for your mod, the most important being <code>gameinfo.txt</code>, <code>bin/client.dll</code> and <code>bin/server.dll</code>.
In order to launch your mod, the necessary files need to be created in your <code>sourcemods</code> folder. The [[Source SDK 2013]] GitHub repo provides some sample Game Directories for you in the <code>game/</code> folder. These folders contain all the necessary assets, binaries and scripts for your mod, the most important being <code>gameinfo.txt</code>, <code>bin/client.dll</code> and <code>bin/server.dll</code>. These Game Directories are automatically configured in Visual Studio to copy over the dlls to their respective <code>bin/</code> folder. This is done in the post build step (see '''Change output directory''' on this page).


* Singleplayer: Copy the directory from <code><your mod>/sp/game/mod_hl2</code> (or <code>mod_episodic</code>) to <code><steam_path>/steamapps/sourcemods/<your mod></code>
* Singleplayer: Copy the directory from <code><your mod>/sp/game/mod_hl2</code> (or <code>mod_episodic</code>) to <code><steam_path>/steamapps/sourcemods/<your mod></code>
Line 8: Line 13:


Restart Steam after this step and you will find your mod listed in your Steam library.
Restart Steam after this step and you will find your mod listed in your Steam library.
{{Warning|It is advised to create a symlink from <code>mod_</code> directory to the <code>sourcemods</code> folder instead, as changes done to the <code>mod_</code> won't be synchronized with the mod folder created inside the <code>steamapps</code> folder.}}
{{Warning|It is advised to create a symlink (which is different to a normal link, see below) from <code>mod_</code> directory to the <code>sourcemods</code> folder instead, as changes done to the <code>mod_</code> won't be synchronized with the mod folder created inside the <code>steamapps</code> folder.}}


Alternatively, in place of the <code>sourcemods</code> method you can drop the directory into the original game's root directory, though this requires use of the <code>-game</code> [[command line options|launch option]].
Alternatively, in place of the <code>sourcemods</code> method you can drop the directory into the original game's root directory, though this requires use of the <code>-game</code> [[command line options|launch option]].

Latest revision as of 11:00, 4 July 2025

Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
Article could be improved to include instructions for Mac/Linux
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

To make a Source mod appear in your Steam library, its Game Directory (the one that has gameinfo.txt inside) must exist as a folder inside steam/steamapps/sourcemods/. Its name, the assets it mounts, and the Source SDK branch it uses is controlled by gameinfo.txt. When the player clicks the play button, Steam will launch the appropriate Source SDK Base, which will attempt to load the mod's client.dll and server.dll from the /bin or /bin/x64/ folder.

You can use Wikipedia icon Symlinks to help make the mod development process more convenient.

Note.pngNote:If you want to distribute the mod on Steam (i.e. the mod has its own Steam page, players download the mod through Steam instead of a 3rd party site), see this Steamworks article.
Tip.pngTip:Changes to your sourcemods directory only appear after you restart Steam. Restart Steam by clicking the small 'Steam' button at the top-left of the Steam window, and then clicking 'Exit'. After it closes, open Steam again.

Mod files

In order to launch your mod, the necessary files need to be created in your sourcemods folder. The Source SDK 2013 GitHub repo provides some sample Game Directories for you in the game/ folder. These folders contain all the necessary assets, binaries and scripts for your mod, the most important being gameinfo.txt, bin/client.dll and bin/server.dll. These Game Directories are automatically configured in Visual Studio to copy over the dlls to their respective bin/ folder. This is done in the post build step (see Change output directory on this page).

  • Singleplayer: Copy the directory from <your mod>/sp/game/mod_hl2 (or mod_episodic) to <steam_path>/steamapps/sourcemods/<your mod>
  • Multiplayer: Copy the directory from <your mod>/mp/game/mod_hl2mp (or mod_tf2) to <steam_path>/steamapps/sourcemods/<your mod>

Restart Steam after this step and you will find your mod listed in your Steam library.

Warning.pngWarning:It is advised to create a symlink (which is different to a normal link, see below) from mod_ directory to the sourcemods folder instead, as changes done to the mod_ won't be synchronized with the mod folder created inside the steamapps folder.

Alternatively, in place of the sourcemods method you can drop the directory into the original game's root directory, though this requires use of the -game launch option.

Symlink mod directory

It would get tedious to copy over the mod directory every time we build our binaries, so instead we can symlink our mod_ folder so that it is always up-to-date. First, delete the folder we created in the previous step under sourcemods/ (if you have no other mods installed, this directory should be empty now).

  1. Open up your command prompt or terminal.
  2. Navigate to directory <steam_path>/steamapps/sourcemods/
  3. Create a symlink to your mod directory
  • Windows:
mklink /J <mod_name> "<path_to_source>/<sp|mp>/game/<mod_hl2mp|mod_hl2|mod_episodic>"
  • Linux:
mkdir <mod_name> && sudo mount --bind <path_to_source>/<sp|mp>/game/<mod_hl2mp|mod_hl2|mod_episodic> <mod_name>

Now, every time you update assets or rebuild your code in your game/mod_ directory the changes will automatically be there the next time you launch your mod.

Change output directory

You can change the output directory of your binaries to something other than mod_hl2, mod_episodic or mod_hl2mp by right clicking Project -> Properties -> Build events -> Post build events and changing the paths as desired. This must be done for both Client and Server.

Example:

if not exist "..\..\..\game\MY_MOD\bin\." mkdir "..\..\..\game\MY_MOD\bin\."
copy "$(TargetDir)$(TargetFileName)" "..\..\..\game\MY_MOD\bin\.\$(TargetFileName)"
if ERRORLEVEL 1 goto BuildEventFailed
if exist "$(TargetDir)$(TargetName).map" copy "$(TargetDir)$(TargetName).map" ..\..\..\game\MY_MOD\bin\.\$(TargetName).map
copy "$(TargetDir)$(TargetName).pdb" ..\..\..\game\MY_MOD\bin\.\$(TargetName).pdb
if ERRORLEVEL 1 goto BuildEventFailed
goto BuildEventOK
:BuildEventFailed
echo *** ERROR! PostBuildStep FAILED for $(ProjectName)! EXE or DLL is probably running. ***
del /q "$(TargetDir)$(TargetFileName)"
exit 1
:BuildEventOK

Problems with running your mod

If, at startup, after the intro video, your mod crashes while Steam is active, but it runs without problem if Steam is shut down, then you follow these instructions:

  1. - to Open file steam_api.h (src\public\steam)
  2. - Find this and DELETE/COMMENT (Lines 551 - 562):
	m_pSteamMusicRemote = SteamClient()->GetISteamMusicRemote( hSteamUser, hSteamPipe, STEAMMUSICREMOTE_INTERFACE_VERSION );
	if ( !m_pSteamMusicRemote )
	{
		return false;
	}
	
	m_pSteamHTMLSurface = SteamClient()->GetISteamHTMLSurface( hSteamUser, hSteamPipe, STEAMHTMLSURFACE_INTERFACE_VERSION );
	if ( !m_pSteamHTMLSurface )
	{
		return false;
	}