void BaseSystem::ncz_cmd_fn ( const SourceSdk::CCommand &args ) { if( args.ArgC () > 1 ) { BaseSystem* it = GetFirst (); while( it != nullptr ) { if( stricmp ( it->GetName (), args.Arg ( 1 ) ) == 0 ) { if( stricmp ( "enable", args.Arg ( 2 ) ) == 0 ) { it->SetConfig ( true ); it->SetActive ( true ); } else if( stricmp ( "disable", args.Arg ( 2 ) ) == 0 ) { it->SetConfig ( false ); it->SetActive ( false ); } else if( stricmp ( "verbose", args.Arg ( 2 ) ) == 0 ) { if( args.ArgC () > 2 ) { it->m_verbose = atoi ( args.Arg ( 3 ) ); } return; } #ifdef NCZ_USE_METRICS else if( Helpers::bStriEq ( "printmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().PrintAll (); } else if( Helpers::bStriEq ( "resetmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().ResetAll (); } #endif else if( !it->sys_cmd_fn ( args ) ) { printf ( "action %s not found.\nTry : %s\n", args.Arg ( 2 ), it->cmd_list () ); } return; } GetNext ( it ); } printf ( "System %s not found.\n", args.Arg ( 1 ) ); } else { printf ( "Usage: ncz system arg1 arg2 ...\n" ); printf ( "Systems list :\n" ); BaseSystem* it ( GetFirst () ); while( it != nullptr ) { printf ( "%s", it->GetName () ); if( it->IsActive () ) { printf ( " (Running)\n" ); } else if( !it->IsEnabledByConfig () ) { printf ( " (Disabled manually)\n" ); } else if( it->GetDisabledByConfigIni () ) { printf ( " (Disabled by config.ini)\n" ); } else { printf ( " (Sleeping - Waiting for players)\n" ); } printf ( "\tCommands : %s\n", it->cmd_list () ); GetNext ( it ); } } }
void BaseSystem::ncz_cmd_fn ( const SourceSdk::CCommand &args ) { if( args.ArgC () > 1 ) { BaseSystem* it = GetFirst (); while( it != nullptr ) { if( stricmp ( it->GetName (), args.Arg ( 1 ) ) == 0 ) { if( stricmp ( "enable", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( true ); it->SetActive ( true ); } } else if( stricmp ( "disable", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( false ); it->SetActive ( false ); } } else if( stricmp ( "on", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( true ); it->SetActive ( true ); } } else if( stricmp ( "off", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( false ); it->SetActive ( false ); } } else if( stricmp ( "verbose", args.Arg ( 2 ) ) == 0 ) { if( args.ArgC () > 2 ) { it->m_verbose = atoi ( args.Arg ( 3 ) ); Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s verbose level is now %d", it->GetName (), it->m_verbose ) ); } return; } #ifdef NCZ_USE_METRICS else if( Helpers::bStriEq ( "printmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().PrintAll (); } else if( Helpers::bStriEq ( "resetmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().ResetAll (); } #endif else if( !it->sys_cmd_fn ( args ) ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "action %s not found.\nTry : %s", args.Arg ( 2 ), it->cmd_list () ) ); } return; } GetNext ( it ); } Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s not found.", args.Arg ( 1 ) ) ); } else { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( "Usage: ncz system arg1 arg2 ...\nSystems list :\n"); BaseSystem* it ( GetFirst () ); while( it != nullptr ) { basic_string prepared_message ( it->GetName () ); if( it->IsStatic () ) { prepared_message.append ( " (Static)\n" ); } else if( it->IsActive () ) { prepared_message.append ( " (Running)\n" ); } else if( !it->IsEnabledByConfig () ) { prepared_message.append ( " (Disabled manually)\n" ); } else if( it->GetDisabledByConfigIni () ) { prepared_message.append ( " (Disabled by config.ini)\n" ); } else { prepared_message.append ( " (Sleeping - Waiting for players)\n" ); } prepared_message.append ( Helpers::format( "\tCommands : %s\n", it->cmd_list () ) ); Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( prepared_message.c_str () ); GetNext ( it ); } } }