diff --git a/src/game/client/vscript_client.cpp b/src/game/client/vscript_client.cpp index 57e00dc54..c9326377d 100644 --- a/src/game/client/vscript_client.cpp +++ b/src/game/client/vscript_client.cpp @@ -186,6 +186,9 @@ bool VScriptClientInit() g_pScriptVM->Run( g_Script_vscript_client ); } + // ignore map-packed serverspawn files, allows server owners to run scripts before the map + VScriptRunScript( "serverspawn", false ); + VScriptRunScript( "mapspawn", false ); VMPROF_SHOW( pszScriptLanguage, "virtual machine startup" ); diff --git a/src/game/server/vscript_server.cpp b/src/game/server/vscript_server.cpp index 43ff4f530..1426f098f 100644 --- a/src/game/server/vscript_server.cpp +++ b/src/game/server/vscript_server.cpp @@ -3503,6 +3503,9 @@ REGISTER_SCRIPT_CONST_TABLE( Server ) } g_VScriptGameEventListener.Init(); + // ignore map-packed serverspawn files, allows server owners to run scripts before the map + VScriptRunScript( "serverspawn", false ); + VScriptRunScript( "mapspawn", false ); if ( script_connect_debugger_on_mapspawn.GetBool() ) diff --git a/src/game/shared/vscript_shared.cpp b/src/game/shared/vscript_shared.cpp index 64088e109..0a7814d08 100644 --- a/src/game/shared/vscript_shared.cpp +++ b/src/game/shared/vscript_shared.cpp @@ -1,4 +1,4 @@ -//========== Copyright © 2008, Valve Corporation, All rights reserved. ======== +//========== Copyright � 2008, Valve Corporation, All rights reserved. ======== // // Purpose: // @@ -102,7 +102,17 @@ HSCRIPT VScriptCompileScript( const char *pszScriptName, bool bWarnMissing ) } else { - bool bResult = filesystem->ReadFile( scriptPath, "GAME", bufferScript ); + bool bResult = false; + + // ignore map-packed serverspawn files, allows server owners to run scripts before the map + if ( V_strcmp( pszScriptName, "serverspawn" ) == 0 || V_strcmp( pszScriptName, CFmtStr( "serverspawn%s", pszVMExtension ) ) == 0 ) + { + bResult = filesystem->ReadFile( scriptPath, "MOD", bufferScript ); + } + else + { + bResult = filesystem->ReadFile( scriptPath, "GAME", bufferScript ); + } if( !bResult ) {