--
[ Picked text/plain from multipart/alternative ]
Sorry I forgot about this function :
void CreateGameRulesObject( const char *pClassName )
{
// Delete the old game rules object.
delete g_pGameRules;
g_pGameRules = NULL;
// Create a new game rules object.
CGameRulesRegister *pReg = CGameRulesRegister::FindByName(
pClassName );
if ( !pReg )
Error( "InitGameRules: missing gamerules class '%s' on the
server", pClassName );
pReg->CreateGameRules( );
if ( !g_pGameRules )
{
Error( "InitGameRules: game rules entity (%s) not
created", pClassName );
}
}
and to avoid malloc warnings
#include <string>
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
put <string> before memdgbon as stated ;)
On 4/11/07, Emiel Regis <[EMAIL PROTECTED]> wrote:
>
> 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