e(forgive me for all errors im am a newf)//End Exscuse continue bad grammer
Hey this was an original tutorial by Hypothermia for Quake 3 ive migrated into Et and it works Excellent, what we are going to do is have et execute mapdefault.cfg everytime a level is loaded and <mapname>.cfg aswell (ie fueldump.cfg if et was loading the map fueldump). The whole purpose of doing this is if your mod has a lot of cvars to and/or as a tool for server adminastration, The possibilities of this are endless and it is very usefull, there is many ways of doing this probably without even touching the source but i thought it might help some people who want to execute console commands at level load in the code or whatever. Anyway, the first thing you need to do is open up g_local.h and around line 1788 just after
extern vmCvar_t bot_debug_anim;
Givem one of these numbers (insert the following code):
//Jeremy: time for me to get my 2 cents in
extern vmCvar_t g_ExecMapConfigs;
//Jeremy: end 2 cents
then we want to hit up g_main.c for more excitement after
vmCvar_t g_disableComplaints;
add this
vmCvar_t g_ExecMapConfigs; //Map cfg files Cvar
Now you need to make sure we add our cvar to gameCvarTable[] which is located just a little further down in g_main.c, I added it into to then end, so i added this about line 429
,
{ &g_ExecMapConfigs, "g_ExecMapConfigs", "1", CVAR_ARCHIVE, 0, qfalse}
Alrighty then, well we just created a new cvar g_ExecMapConfigs, Now hopefully you have a better understanding of how to toss some new cvar’s into the mix. The next thing we will be doing is getting the server to execute these configs open up g_spawn.c and head on down to G_SpawnEntitiesFromString() …you there? okay now just after this fancy one liner on line 1022
void G_SpawnEntitiesFromString( void )
add this even fancier one liner
char info[1024];
Now in that same function just below
SP_worldspawn();
add this code
// Jeremy: exec individual map configs if CVAR is set
if (g_ExecMapConfigs.integer)
{
trap_SendConsoleCommand( EXEC_APPEND, "exec mapdefault.cfg
");
trap_GetServerinfo(info, sizeof(info));
trap_SendConsoleCommand( EXEC_APPEND, va("exec %s.cfg
",Info_ValueForKey( info, “mapname” )));
}
//Jeremy: end
that’s tellin the server if our CVAR has a value other than 0, then add 2 commands to its command list to be executed. First, we tell it to exec mapdefault.cfg, Then, we load up the server info keys, grab name of the current map, and then exec our .cfg file if present (note: none of these files even mapdefault.cfg are nessecary to be present) Then ur ready to rock and roll, I used this as a dirty deprave hack in a q3 mod for level cycling and im sure u can think up some other fun things, enjoy! (oh yeah remember u need to add
+set g_ExecMapConfigs 1
to the command line
I am not or do not claim to be an ansi c wiz of any sort
