Exemplo n.º 1
0
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 );
		}
	}
}
Exemplo n.º 2
0
bool BanRequest::sys_cmd_fn ( const SourceSdk::CCommand &args )
{
	if( stricmp ( "CanKick", args.Arg ( 2 ) ) == 0 )
	{
		if(Helpers::IsArgTrue(args.Arg(3)))
		{
			m_can_kick = true;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else if (Helpers::IsArgFalse(args.Arg(3)))
		{
			m_can_kick = false;
			m_can_ban = false;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else
		{
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "Available arguments for \"ncz BanRequest CanKick\" : Yes - No" ) );
		}

		g_Logger.Msg<MSG_CMD_REPLY>(Helpers::format("NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString(m_can_kick), Helpers::boolToString(m_can_ban)));
		return true;
	}
	else if( stricmp ( "CanBan", args.Arg ( 2 ) ) == 0 )
	{
		if(Helpers::IsArgTrue(args.Arg(3)))
		{
			m_can_kick = true;
			m_can_ban = true;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else if(Helpers::IsArgFalse(args.Arg(3)))
		{
			m_can_ban = false;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else
		{
			g_Logger.Msg<MSG_CMD_REPLY> ( "Available arguments for \"ncz BanRequest CanBan\" : Yes - No" );
		}
		g_Logger.Msg<MSG_CMD_REPLY>(Helpers::format("NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString(m_can_kick), Helpers::boolToString(m_can_ban)));
		return true;
	}
	else if (stricmp("SetBanTime", args.Arg(2)) == 0)
	{
		if (args.ArgC() >= 4)
		{
			m_ban_time = atoi(args.Arg(3));
		}
		else
		{
			g_Logger.Msg<MSG_CMD_REPLY>("SetBanTime expected int argument (ban time minutes - 0 = permanent)");
		}
		return true;
	}
	else if (stricmp("AllowWriteBans", args.Arg(2)) == 0)
	{
		if (args.ArgC() >= 4)
		{
			if (Helpers::IsArgTrue(args.Arg(3)))
			{
				m_can_write_ids = true;
				g_Logger.Msg<MSG_CMD_REPLY>("AllowWriteBans is Yes");
				return true;
			}
			else if (Helpers::IsArgFalse(args.Arg(3)))
			{
				m_can_write_ids = false;
				g_Logger.Msg<MSG_CMD_REPLY>("AllowWriteBans is No");
				return true;
			}
		}
		g_Logger.Msg<MSG_CMD_REPLY>("AllowWriteBans expected Yes or No");
		return true;
	}
	else
	{
		return false;
	}
}
Exemplo n.º 3
0
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 );
		}		
	}
}