|
|
|
Well looks like I am still here writing tutorials =-). This is just a simple way to switch to different gameplay modes. Open up gamerules.cpp and down at the very bottom there is a function called InstallGameRules. Change the whole function to CGameRules *InstallGameRules( void ) { SERVER_COMMAND( "exec game.cfg\n" ); SERVER_EXECUTE( ); if ( !gpGlobals->deathmatch ) { // generic half-life return new CHalfLifeRules; } else { const char *szMapName = (STRING(gpGlobals->mapname)); if(strncmp(szMapName, "tm_", 3) == 0) { // Teamplay rules return new CHalfLifeTeamplay; } else { // vanilla deathmatch return new CHalfLifeMultiplay; } } } If it is not a multiplayer game then it defaults to the generic Half-Life rules, single player. If it is multiplayer it then checks the first 3 letters of the map name. BEGINNERS NOTE: the usage for strncmp is strncmp(const char* str1, const char* str2, int n) the first two character pointers (strings or characters) are what you are comparing, the number is how many letters of each word you are comparing, since all you are doing is calling a standard function it has a return value, if it returns 0 then both the compared letters of the strings are the same. This checks for the map name beginning with tm_, replace tm_ with what ever you want i.e. tc_. If it begins with tm_ the it allocates the memory for the CHalfLifeTeamplay class, and you will have the game mode of teamplay :). Replace CHalfLifeTeamplay with the class name for the gameplay mode you are implementing in your mod. This was made by request of [gwt]Karl[stc] from the Gansta Wars mod.
Any questions or suggestions should be sent to me:
british@epix.net