Yeah, I noticed that too after compiler bitching. But I recompiled and it shut up so I thought that maybe string class has overriden == operator, like string_t in Source has ;)
On Wed, 11 Apr 2007 09:31:16 +0200, Mark Chandler <[EMAIL PROTECTED]> wrote:
In c++ you cant use == when comparing strings *because it will compare a pointer instead of the string for vars. Use strcmp so it would be something like this: if (!strcmp(mapName ,"dm_")) // Classic SourceForts CTF { CreateGameRulesObject( "C_HL2MPRules" ); } else if (!strcmp(mapName, "ctf_")) // Core Run map { CreateGameRulesObject( "C_CTFRules" ); } else if (!strcmp(mapName, "mbs_")) // Conquest map { CreateGameRulesObject( "C_MBSRules" ); } -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Emiel Regis Sent: Wednesday, April 11, 2007 6:37 AM To: [email protected] Subject: Re: [hlcoders] Map gametype filter Thanks for your help. However I'm having some problems, namely: void C_World::InstallGameRules() { char mapN[64]; V_FileBase( engine->GetLevelName( ), mapN, 64 ); string mapName = mapN; mapName = mapName.substr( 0, 3 ); if (mapName == "dm_") // Classic SourceForts CTF { CreateGameRulesObject( "C_HL2MPRules" ); } else if (mapName == "ctf_") // Core Run map { CreateGameRulesObject( "C_CTFRules" ); } else if (mapName == "mbs_") // Conquest map { CreateGameRulesObject( "C_MBSRules" ); } else CreateGameRulesObject( "C_HL2MPRules" ); } I use following code, yet it gives me errors: error C3861: 'CreateGameRulesObject': identifier not found And some warning about malloc redefinition. I use #include <string> and using std::string; .-- [ Picked text/plain from multipart/alternative ] Hi emiel, For SourceForts, I use this : (i use hl2mp sdk) In hl2mp_client.cpp : //========================================================= // instantiate the proper game rules object //========================================================= void InstallGameRules() { std::string mapName = STRING( gpGlobals->mapname ); mapName = mapName.substr( 0, 3 ); if (mapName == "sf_") // Classic SourceForts CTF { CreateGameRulesObject( "CSFCTFGamerules" ); } else if (mapName == "cr_") // Core Run map { CreateGameRulesObject( "CSFCRGamerules" ); } else if (mapName == "cq_") // Conquest map { CreateGameRulesObject( "CHL2MPRules" ); } else CreateGameRulesObject( "CSFCTFGamerules" ); } InstallGamerules is already called automatically. Thought (note to valve) it seems client side the networktable is not updated for gamerules object.So when it's creating a new one server side, client side it remains the old one. So you'll have to make the samefunction client side in C_World::Precache( ) and use char mapN[64]; V_FileBase( engine->GetLevelName( ), mapN, 64 ); std::string mapName = mapN; mapName = mapName.substr( 0, 3 ); instead of std::string mapName = STRING( gpGlobals->mapname ); I hope I helped you._______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

