Hey y'all, am having trouble with my round timer/map reset..........was working before but now is has a glitch or something. Was wondering anyone out there can help me get this going.........the problem is that the team scores are erased at each map reset, I need the scores to stay for every round.....anyway here's the code am using......
=========== Mapfilter.h ========== #include "cbase.h" #include "mapentities.h" #include "UtlSortVector.h" #ifndef CMAPENTITYFILTER_H #define CMAPENTITYFILTER_H typedef const char* strptr; static bool StrLessThan( const strptr &src1, const strptr &src2, void *pCtx ) { if( strcmp(src1, src2) >= 0) return false; else return true; } class CMapEntityFilter : public IMapEntityFilter { public: // constructor CMapEntityFilter(); // deconstructor ~CMapEntityFilter(); // used to check if we should reset an entity or not virtual bool ShouldCreateEntity( const char *pClassname ); // creates the next entity in our stored list. virtual CBaseEntity* CreateNextEntity( const char *pClassname ); // add an entity to our list void AddKeep( const char*); private: // our list of entities to keep CUtlSortVector< const char* > *keepList; }; #endif ============ Mapfilter.cpp ============ #include "cbase.h" #include "mapfilter.h" // Constructor CMapEntityFilter::CMapEntityFilter() { keepList = new CUtlSortVector< const char *> (StrLessThan); } // Deconstructor CMapEntityFilter::~CMapEntityFilter() { delete keepList; } // [bool] ShouldCreateEntity [char] // Purpose : Used to check if the passed in entity is on our stored list // Arguments : The classname of an entity // Returns : Boolean value - if we have it stored, we return false. bool CMapEntityFilter::ShouldCreateEntity( const char *pClassname ) { //Check if the entity is in our keep list. if( keepList->Find( pClassname ) >= 0 ) return false; else return true; } // [CBaseEntity] CreateNextEntity [char] // Purpose : Creates an entity // Arguments : The classname of an entity // Returns : A pointer to the new entity CBaseEntity* CMapEntityFilter::CreateNextEntity( const char *pClassname ) { return CreateEntityByName( pClassname); } // [void] AddKeep [char] // Purpose : Adds the passed in value to our list of items to keep // Arguments : The class name of an entity // Returns : Void void CMapEntityFilter::AddKeep( const char *sz) { keepList->Insert(sz); } ================== ent_restartround.cpp ================== #include "cbase.h" #include "entityinput.h" #include "entityoutput.h" #include "eventqueue.h" #include "mathlib.h" #include "globalstate.h" #include "ndebugoverlay.h" #include "vstdlib/random.h" #ifndef CLIENT_DLL #include "mapfilter.h" #endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" class CRestartRoundEntity: public CLogicalEntity { public: DECLARE_CLASS( CRestartRoundEntity, CLogicalEntity ); void InputRestart( inputdata_t &inputdata ); private: DECLARE_DATADESC(); }; LINK_ENTITY_TO_CLASS( restart_round, CRestartRoundEntity); BEGIN_DATADESC( CRestartRoundEntity) DEFINE_INPUTFUNC( FIELD_VOID, "RestartRound", InputRestart ), END_DATADESC(); void CRestartRoundEntity::InputRestart( inputdata_t &inputdata ) { CMapEntityFilter filter; //keep all of these entities (ie don't remove them) filter.AddKeep("worldspawn"); filter.AddKeep("soundent"); filter.AddKeep("hl2mp_gamerules"); filter.AddKeep("scene_manager"); filter.AddKeep("predicted_viewmodel"); filter.AddKeep("team_manager"); filter.AddKeep("event_queue_saveload_proxy"); filter.AddKeep("player_manager"); filter.AddKeep("player"); filter.AddKeep( "restart_round" ); CBaseEntity *pEnt; CBaseEntity *tmpEnt; pEnt = gEntList.FirstEnt(); while (pEnt != NULL) { if ( filter.ShouldCreateEntity (pEnt->GetClassname() ) ) { tmpEnt = gEntList.NextEnt (pEnt); UTIL_Remove (pEnt); pEnt = tmpEnt; } else { pEnt = gEntList.NextEnt (pEnt); } } gEntList.CleanupDeleteList(); MapEntity_ParseAllEntities( engine->GetMapEntitiesString(), &filter, true); //spawn each player for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *plr = UTIL_PlayerByIndex( i ); if ( plr ) { plr->Spawn(); } else { break; } } } -------------------------- Best regards. Gus [EMAIL PROTECTED] 2006-02-02 _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders