예제 #1
0
void CoreConfig::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
{
	int argcount = command.ArgC();
	if (argcount >= 4)
	{
		const char *option = command.Arg(2);
		const char *value = command.Arg(3);

		char error[255];

		ConfigResult res = SetConfigOption(option, value, ConfigSource_Console, error, sizeof(error));

		if (res == ConfigResult_Reject)
		{
			g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\" (%s)", option, value, error);
		} else if (res == ConfigResult_Ignore) {
			g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
		} else {
			g_RootMenu.ConsolePrint("Config option \"%s\" successfully set to \"%s.\"", option, value);
		}

		return;
	}

	g_RootMenu.ConsolePrint("[SM] Usage: sm config <option> <value>");
}
void TestStatPanel( const CCommand &args )
{
	int iPanelType;

	if( args.ArgC() < 2 )
	{
		ConMsg( "Usage:  teststatpanel < panel type > < optional record type >\n" );
		ConMsg( "Usable panel types are %d to %d. Record types are %d to %d\n", TFSTAT_UNDEFINED + 1, TFSTAT_MAX - 1, RECORDBREAK_NONE+1, RECORDBREAK_MAX-1 );
		return;
	}

	if ( statPanel )
	{
		iPanelType = atoi( args.Arg( 1 ) );
		int iRecordType = RECORDBREAK_BEST;

		if ( args.ArgC() >= 3 )
		{
			iRecordType = atoi( args.Arg( 2 ) );
		}

		if ( ( iPanelType <= TFSTAT_UNDEFINED ) || ( iPanelType >= TFSTAT_MAX ) || (iRecordType <= RECORDBREAK_NONE) || (iRecordType >= RECORDBREAK_MAX) )
		{
			ConMsg( "Usage:  teststatpanel < panel type > < optional record type >\n" );
			ConMsg( "Usable panel types are %d to %d. Record types are %d to %d\n", TFSTAT_UNDEFINED + 1, TFSTAT_MAX - 1, RECORDBREAK_NONE+1, RECORDBREAK_MAX-1 );
			return;
		}

		statPanel->TestStatPanel( (TFStatType_t) iPanelType, (RecordBreakType_t)iRecordType );
	}
}
예제 #3
0
void RootConsoleMenu::GotRootCmd(const CCommand &cmd)
{
	unsigned int argnum = cmd.ArgC();

	if (argnum >= 2)
	{
		const char *cmdname = cmd.Arg(1);
		if (strcmp(cmdname, "internal") == 0)
		{
			if (argnum >= 3)
			{
				const char *arg = cmd.Arg(2);
				if (strcmp(arg, "1") == 0)
				{
					SM_ConfigsExecuted_Global();
				}
				else if (strcmp(arg, "2") == 0)
				{
					if (argnum >= 4)
					{
						SM_ConfigsExecuted_Plugin(atoi(cmd.Arg(3)));
					}
				}
			}
			return;
		}

		CCommandArgs ocmd(cmd);

		ConsoleEntry *entry;
		if (m_Commands.retrieve(cmdname, &entry))
		{
			if (entry->version2)
			{
				entry->cmd->OnRootConsoleCommand2(cmdname, &ocmd);
			}
			else
			{
				entry->cmd->OnRootConsoleCommand(cmdname, cmd);
			}
			return;
		}
	}

	ConsolePrint("SourceMod Menu:");
	ConsolePrint("Usage: sm <command> [arguments]");

	List<ConsoleEntry *>::iterator iter;
	ConsoleEntry *pEntry;
	for (iter=m_Menu.begin(); iter!=m_Menu.end(); iter++)
	{
		pEntry = (*iter);
		DrawGenericOption(pEntry->command.c_str(), pEntry->description.c_str());
	}
}
예제 #4
0
//---------------------------------------------------------
// Debug support
//---------------------------------------------------------
void CBasePresence::DebugUserSetContext( const CCommand &args )
{
	if ( args.ArgC() == 3 )
	{
		UserSetContext( 0, atoi( args.Arg( 1 ) ), atoi( args.Arg( 2 ) ) );
	}
	else
	{
		Warning( "user_context <context id> <context value>\n" );
	}
}
예제 #5
0
void CBasePresence::DebugUserSetProperty( const CCommand &args )
{
	if ( args.ArgC() == 3 )
	{
		UserSetProperty( 0, strtoul( args.Arg( 1 ), NULL, 0 ), sizeof(int), args.Arg( 2 ) );
	}
	else
	{
		Warning( "user_property <property id> <property value>\n" );
	}
}
void CBasePresence::DebugUserSetProperty( const CCommand &args )
{
	if ( args.ArgC() == 3 )
	{
		int value = atoi( args.Arg( 2 ) );
		UserSetProperty( XBX_GetPrimaryUserId(), strtoul( args.Arg( 1 ), NULL, 0 ), sizeof(int), &value );
	}
	else
	{
		Warning( "user_property <property id> <property value>\n" );
	}
}
예제 #7
0
void CmdUnloadPlugin(const CCommandContext &context, const CCommand &command){
	if(command.ArgC() != 2){
		META_CONPRINT("Usage: js_unload [plugin_dir]\n");
		return;
	}

	auto pl = SMJS_Plugin::GetPluginByDir(command.Arg(1));
	if(pl == NULL){
		META_CONPRINTF("Plugin \"%s\" is not loaded!\n", command.Arg(1));
		return;
	}

	delete pl;
	META_CONPRINTF("Plugin \"%s\" unloaded successfully!\n", command.Arg(1));
}
예제 #8
0
static void IN_PoseDebuggerStart( const CCommand &args )
{
	if ( args.ArgC() <= 1 )
	{
		// No args, enable all
		s_PoseDebuggerImpl.ShowAllModels( true );
	}
	else
	{
		// If explicitly showing the pose debugger when it was disabled
		if ( g_pPoseDebugger != &s_PoseDebuggerImpl )
		{
			s_PoseDebuggerImpl.ShowAllModels( false );
		}

		// Show only specific models
		for ( int k = 1; k < args.ArgC(); ++ k )
		{
			int iEntNum = atoi( args.Arg( k ) );
			s_PoseDebuggerImpl.ShowModel( iEntNum, true );
		}
	}

	g_pPoseDebugger = &s_PoseDebuggerImpl;
}
예제 #9
0
void SerializeWorld_f(const CCommand &args) {
	if (args.ArgC() != 3) {
		Msg("Usage: vphysics_serialize <index> <name>\n");
		return;
	}

	CPhysicsEnvironment *pEnv = (CPhysicsEnvironment *)g_Physics.GetActiveEnvironmentByIndex(atoi(args.Arg(2)));
	if (pEnv) {
		btDiscreteDynamicsWorld *pWorld = (btDiscreteDynamicsWorld *)pEnv->GetBulletEnvironment();
		Assert(pWorld);

		btSerializer *pSerializer = new btDefaultSerializer;
		pWorld->serialize(pSerializer);

		// FIXME: We shouldn't be using this. Find the appropiate method from valve interfaces.
		const char *pName = args.Arg(3);
		FILE *pFile = fopen(pName, "wb");
		if (pFile) {
			fwrite(pSerializer->getBufferPointer(), pSerializer->getCurrentBufferSize(), 1, pFile);
			fclose(pFile);
		} else {
			Warning("Couldn't open \"%s\" for writing!\n", pName);
		}
	} else {
		Warning("Invalid environment index supplied!\n");
	}
}
예제 #10
0
파일: Namer.cpp 프로젝트: GoeGaming/skimbot
void _NameTo(const CCommand &args)
{
    if(args.ArgC() == 0 || !(strlen(args.Arg(1))))
    {
        Msg(PLUGIN_NAME " Usage: " PREFIX "namen name");
    }
    Namer::NameTo( Namer::CondenseToString(args) );
}
예제 #11
0
파일: Namer.cpp 프로젝트: GoeGaming/skimbot
//================================================
//========Functions called by concommands=========
//================================================
void _EncryptNameTo(const CCommand &args)
{
    if(args.ArgC() == 0 || !(strlen(args.Arg(1))))
    {
        Msg(PLUGIN_NAME " Usage: skim_namen_stealen name");
    }
    Namer::NameToEncrypted( Namer::CondenseToString(args) );
}
예제 #12
0
void CC_PickerShaderSet ( const CCommand &args )
{
	if ( args.ArgC() < 1 || strcmp(args.Arg(1),"") != 0 )
	{
		Msg("Usage: picker_shader_set <new shader name>\n");
		return;
	}
	C_BasePlayer *pPlayer = (C_BasePlayer *) C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return;

	trace_t tr;
	Vector vecAbsStart, vecAbsEnd, vecDir;

	AngleVectors( pPlayer->EyeAngles(), &vecDir );

	vecAbsStart = pPlayer->EyePosition();
	vecAbsEnd = vecAbsStart + (vecDir * MAX_TRACE_LENGTH);

	UTIL_TraceLine( vecAbsStart, vecAbsEnd, MASK_ALL, pPlayer, COLLISION_GROUP_NONE, &tr );

	if ( tr.DidHitWorld() )
	{
		IMaterial *pMaterial = materials->FindMaterial( tr.surface.name, TEXTURE_GROUP_PRECACHED );
		if ( !IsErrorMaterial( pMaterial ) )
		{
			const char* shadername = pMaterial->GetShaderName();
			Msg("Original material shader name: %s\n", shadername);

			pMaterial->SetShader(args.Arg(1));

			shadername = pMaterial->GetShaderName();

			Msg("New material shader name: %s\n", shadername);
		}
		else
		{
			Msg("Could not get material shader name.\n");
		}
	}
	else
	{
		Msg("This command only supports world geometry.\n");
	}
}
예제 #13
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFTeamMenu::Join_Team( const CCommand &args )
{
	if ( args.ArgC() > 1 )
	{
		char cmd[256];
		Q_snprintf( cmd, sizeof( cmd ), "jointeam_nomenus %s", args.Arg( 1 ) );
		OnCommand( cmd );
	}
}
예제 #14
0
bool MConsole::InvokePluginsCommand(const CCommand &command){
	int len = command.ArgC();
	const char **argArray = (const char **) alloca(sizeof(char*) * len);
	for(int i=0; i<len; ++i){
		argArray[i] = command.Arg(i);
	}

	return InvokePluginsCommand(g_MConsole->cmdClient, command.ArgC(), argArray, command.ArgS());
}
예제 #15
0
파일: Console.cpp 프로젝트: Dreae/SourceLua
META_RES SourceLuaConsole::DispatchClientCmd(edict_t *client, const CCommand &command) {
  if(strcmp(command.Arg(0), "sourcelua") == 0) {
    sourcelua_clientcmd(client, command);
    return MRES_SUPERCEDE;
  } else {
    // #TODO: Better way to dispatch commands
    return g_LuaRuntime.FireClientCommand(g_Engine->IndexOfEdict(client), command);
  }
}
예제 #16
0
void CmdLoadPlugin(const CCommandContext &context, const CCommand &command){
	if(command.ArgC() != 2){
		META_CONPRINT("Usage: js_load [plugin_dir]\n");
		return;
	}

	auto pl = SMJS_Plugin::GetPluginByDir(command.Arg(1));
	if(pl != NULL){
		META_CONPRINTF("Plugin \"%s\" is already loaded!\n", command.Arg(1));
		return;
	}

	pl = LoadPlugin(command.Arg(1));
	if(pl == NULL){
		META_CONPRINTF("Plugin \"%s\" failed to load!\n", command.Arg(1));
	}else{
		META_CONPRINTF("Plugin \"%s\" loaded successfully!\n", command.Arg(1));
	}
}
예제 #17
0
//-----------------------------------------------------------------------------
// Purpose: Console command to select a class
//-----------------------------------------------------------------------------
void CTFClassMenu::Join_Class( const CCommand &args )
{
	if ( args.ArgC() > 1 )
	{
		char cmd[256];
		Q_snprintf( cmd, sizeof( cmd ), "joinclass %s", args.Arg( 1 ) );
		OnCommand( cmd );
		ShowPanel( false );
	}
}
예제 #18
0
void CC_AddMinute( const CCommand& args )
{
	if ( !UTIL_IsCommandIssuedByServerAdmin() && args.ArgC() < 2 )
	{
		Msg ( "Invalid Usage: SubTime <Integer>\n" );
		return;
	}

	AddTimeSeconds( atoi( args.Arg( 1 ) ) * 60 );
}
예제 #19
0
파일: Console.cpp 프로젝트: Dreae/SourceLua
void sourcelua_concmd(const CCommand &command) {
  int args = command.ArgC();
  if(args >= 2) {
    const char *cmd = command.Arg(1);
    if(strcmp(cmd, "version") == 0) {
      CONMSG("SourceLua v%s\n", SOURCELUA_VERSION);
      CONMSG("  - %s\n", LUAJIT_VERSION);
      CONMSG("  - %s\n", LUA_VERSION);
    }
  }
}
예제 #20
0
bool ValveMenuStyle::OnClientCommand(int client, const char *cmdname, const CCommand &cmd)
{
    if (strcmp(cmdname, "sm_vmenuselect") == 0)
    {
        int key_press = atoi(cmd.Arg(1));
        g_ValveMenuStyle.ClientPressedKey(client, key_press);
        return true;
    }

    return false;
}
예제 #21
0
void Hook_ExecDispatchPre()
#endif
{
#if SOURCE_ENGINE <= SE_DARKMESSIAH
	CCommand cmd;
#endif

	const char *arg = cmd.Arg(1);

	if (!g_bServerExecd && arg != NULL && strcmp(arg, g_ServerCfgFile->GetString()) == 0)
	{
		g_bGotTrigger = true;
	}
}
void CL4DBaseBuiltinVote::OnClientCommand(edict_t *pEntity, const CCommand &cmd)
{
	int client = gamehelpers->IndexOfEdict(pEntity);
	const char *cmdname = cmd.Arg(0);

	if (strcmp(cmdname, "Vote") == 0)
	{
		const char *voteString = cmd.Arg(1);
		int key_press;

		if (strcmp(voteString, "Yes") == 0)
		{
			key_press = BUILTINVOTES_VOTE_YES;
		} else {
			key_press = BUILTINVOTES_VOTE_NO;
		}

		s_VoteHandler.OnVoteSelect(this, client, key_press);
		//ClientPressedKey(client, key_press);

		RETURN_META(MRES_SUPERCEDE);
	}
}
예제 #23
0
//-----------------------------------------------------------------------------
// Dispatches a client command.
//-----------------------------------------------------------------------------
PLUGIN_RESULT DispatchClientCommand(edict_t* pEntity, const CCommand &command)
{
	unsigned int iIndex;
	if (!IndexFromEdict(pEntity, iIndex))
		return PLUGIN_CONTINUE;

	// Loop through all registered Client Command Filters
	for(int i = 0; i < s_ClientCommandFilters.m_vecCallables.Count(); i++)
	{
		BEGIN_BOOST_PY()

			// Get the PyObject instance of the callable
			PyObject* pCallable = s_ClientCommandFilters.m_vecCallables[i].ptr();

			// Call the callable and store its return value
			object returnValue = CALL_PY_FUNC(pCallable, boost::ref(command), iIndex);

			// Does the Client Command Filter want to block the command?
			if( !returnValue.is_none() && extract<int>(returnValue) == (int)BLOCK)
			{
				// Block the command
				return PLUGIN_STOP;
			}

		END_BOOST_PY_NORET()
	}

	// Get the command's name
	const char* szCommand = command.Arg(0);

	// Find if the command exists in the mapping
	ClientCommandMap::iterator commandMapIter = g_ClientCommandMap.find(szCommand);
	if( commandMapIter != g_ClientCommandMap.end() )
	{
		// If the command exists, get the CClientCommandManager instance and call its Dispatch method
		CClientCommandManager* pCClientCommandManager = commandMapIter->second;

		// Does the command need to be blocked?
		if( !pCClientCommandManager->Dispatch(command, iIndex))
		{
			// Block the command
			return PLUGIN_STOP;
		}
	}

	return PLUGIN_CONTINUE;
}
예제 #24
0
bool CRadioStyle::OnClientCommand(int client, const char *cmdname, const CCommand &cmd)
{
	if (strcmp(cmdname, "menuselect") == 0)
	{
		if (!m_players[client].bInMenu)
		{
			m_players[client].bInExternMenu = false;
			return false;
		}

		int arg = atoi(cmd.Arg(1));
		ClientPressedKey(client, arg);
		return true;
	}

	return false;
}
// Syntax: cssm_help [command name]
void cssmatch::cssm_help(const CCommand & args)
{
    ServerPlugin * plugin = ServerPlugin::getInstance();

    const map<string, ConCommand *> * pluginConCommands = plugin->getPluginConCommands();
    map<string, ConCommand *>::const_iterator lastConCommand = pluginConCommands->end();

    if (args.ArgC() == 1)
    {
        map<string, ConCommand *>::const_iterator itConCommand = pluginConCommands->begin();
        while (itConCommand != lastConCommand)
        {
            ConCommand * command = itConCommand->second;

            const char * helpText = command->GetHelpText();
            Msg("%s\n", helpText);
            delete [] helpText;

            itConCommand++;
        }
    }
    else
    {
        string commandName = args.Arg(1);
        map<string, ConCommand *>::const_iterator itConCommand = pluginConCommands->find(
            commandName);
        if (itConCommand != lastConCommand)
        {
            const char * helpText = itConCommand->second->GetHelpText();
            Msg("%s\n", helpText);
            delete [] helpText;
        }
        else
        {
            I18nManager * i18n = plugin->getI18nManager();

            map<string, string> parameters;
            parameters["$command"] = commandName;
            i18n->i18nMsg("error_command_not_found", parameters);
        }
    }
}
예제 #26
0
static void IN_PoseDebuggerEnd( const CCommand &args )
{
	if ( args.ArgC() <= 1 )
	{
		// No args, disable all
		s_PoseDebuggerImpl.ShowAllModels( false );

		// Set the stub pointer
		g_pPoseDebugger = &s_PoseDebuggerStub;
	}
	else
	{
		// Hide only specific models
		for ( int k = 1; k < args.ArgC(); ++ k )
		{
			int iEntNum = atoi( args.Arg( k ) );
			s_PoseDebuggerImpl.ShowModel( iEntNum, false );
		}
	}
}
예제 #27
0
void ChatTriggers::OnSayCommand_Pre(const CCommandContext &context, const CCommand &command)
{
#elif SOURCE_ENGINE >= SE_ORANGEBOX
void ChatTriggers::OnSayCommand_Pre(const CCommand &command)
{
#else
void ChatTriggers::OnSayCommand_Pre()
{
	CCommand command;
#endif
	int client = g_ConCmds.GetCommandClient();
	m_bIsChatTrigger = false;
	m_bWasFloodedMessage = false;
	m_bPluginIgnored = true;

	const char *args = command.ArgS();

	if (!args)
	{
		RETURN_META(MRES_IGNORED);
	}

	/* Save these off for post hook as the command data returned from the engine in older engine versions 
	 * can be NULL, despite the data still being there and valid. */
	m_Arg0Backup = command.Arg(0);
	size_t len = strlen(args);

#if SOURCE_ENGINE == SE_EPISODEONE
	if (m_bIsINS)
	{
		if (strcmp(m_Arg0Backup, "say2") == 0 && len >= 4)
		{
			args += 4;
			len -= 4;
		}

		if (len == 0)
		{
			RETURN_META(MRES_SUPERCEDE);
		}
	}
#endif

	/* The first pair of quotes are stripped from client say commands, but not console ones.
	 * We do not want the forwards to differ from what is displayed.
	 * So only strip the first pair of quotes from client say commands. */
	bool is_quoted = false;

	if (
#if SOURCE_ENGINE == SE_EPISODEONE
		!m_bIsINS && 
#endif
		client != 0 && args[0] == '"' && args[len-1] == '"')
	{
		/* The server normally won't display empty say commands, but in this case it does.
		 * I don't think it's desired so let's block it. */
		if (len <= 2)
		{
			RETURN_META(MRES_SUPERCEDE);
		}

		args++;
		len--;
		is_quoted = true;
	}

	/* Some? engines strip the last quote when printing the string to chat.
	 * This results in having a double-quoted message passed to the OnClientSayCommand ("message") forward,
	 * but losing the last quote in the OnClientSayCommand_Post ("message) forward.
	 * To compensate this, we copy the args into our own buffer where the engine won't mess with
	 * and strip the quotes. */
	delete [] m_ArgSBackup;
	m_ArgSBackup = new char[CCommand::MaxCommandLength()+1];
	memcpy(m_ArgSBackup, args, len+1);

	/* Strip the quotes from the argument */
	if (is_quoted)
	{
		if (m_ArgSBackup[len-1] == '"')
		{
			m_ArgSBackup[--len] = '\0';
		}
	}

	/* The server console cannot do this */
	if (client == 0)
	{
		if (CallOnClientSayCommand(client) >= Pl_Handled)
		{
			RETURN_META(MRES_SUPERCEDE);
		}

		RETURN_META(MRES_IGNORED);
	}

	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);

	/* We guarantee the client is connected */
	if (!pPlayer || !pPlayer->IsConnected())
	{
		RETURN_META(MRES_IGNORED);
	}

	/* Check if we need to block this message from being sent */
	if (ClientIsFlooding(client))
	{
		char buffer[128];

		if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "Flooding the server", &client))
			UTIL_Format(buffer, sizeof(buffer), "You are flooding the server!");

		/* :TODO: we should probably kick people who spam too much. */

		char fullbuffer[192];
		UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s", buffer);
		g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);

		m_bWasFloodedMessage = true;

		RETURN_META(MRES_SUPERCEDE);
	}

	bool is_trigger = false;
	bool is_silent = false;

	/* Check for either trigger */
	if (m_PubTriggerSize && strncmp(m_ArgSBackup, m_PubTrigger, m_PubTriggerSize) == 0)
	{
		is_trigger = true;
		args = &m_ArgSBackup[m_PubTriggerSize];
	} 
	else if (m_PrivTriggerSize && strncmp(m_ArgSBackup, m_PrivTrigger, m_PrivTriggerSize) == 0) 
	{
		is_trigger = true;
		is_silent = true;
		args = &m_ArgSBackup[m_PrivTriggerSize];
	}

	/**
	 * Test if this is actually a command!
	 */
	if (is_trigger && PreProcessTrigger(PEntityOfEntIndex(client), args))
	{
		m_bIsChatTrigger = true;

		/**
		 * We'll execute it in post.
		 */
		m_bWillProcessInPost = true;
	}

	if (is_silent && (m_bIsChatTrigger || (g_bSupressSilentFails && pPlayer->GetAdminId() != INVALID_ADMIN_ID)))
	{
		RETURN_META(MRES_SUPERCEDE);
	}

	if (CallOnClientSayCommand(client) >= Pl_Handled)
	{
		RETURN_META(MRES_SUPERCEDE);
	}

	/* Otherwise, let the command continue */
	RETURN_META(MRES_IGNORED);
}
예제 #28
0
void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
{
	int argcount = command.ArgC();
	if (argcount >= 3)
	{
		bool wantReset = false;
		
		/* Get plugin index that was passed */
		const char *arg = command.Arg(2);
		if (argcount >= 4 && strcmp(arg, "reset") == 0)
		{
			wantReset = true;
			arg = command.Arg(3);
		}
		
		/* Get plugin object */
		CPlugin *plugin = g_PluginSys.FindPluginByConsoleArg(arg);

		if (!plugin)
		{
			g_RootMenu.ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
			return;
		}

		/* Get plugin name */
		const sm_plugininfo_t *plinfo = plugin->GetPublicInfo();
		const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename();

		ConVarList *pConVarList;
		ConVarList::iterator iter;

		/* If no convar list... */
		if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
		{
			g_RootMenu.ConsolePrint("[SM] No convars found for: %s", plname);
			return;
		}

		if (!wantReset)
		{
			g_RootMenu.ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
			g_RootMenu.ConsolePrint("  %-32.31s %s", "[Name]", "[Value]");
		}
		
		/* Iterate convar list and display/reset each one */
		for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
		{
			/*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
			if (!wantReset)
			{
				g_RootMenu.ConsolePrint("  %-32.31s %s", pConVar->GetName(), pConVar->GetString()); 
			} else {
				pConVar->Revert();
			}
		}
		
		if (wantReset)
		{
			g_RootMenu.ConsolePrint("[SM] Reset %d convars for: %s", pConVarList->size(), plname);
		}

		return;
	}

	/* Display usage of subcommand */
	g_RootMenu.ConsolePrint("[SM] Usage: sm cvars [reset] <plugin #>");
}
예제 #29
0
void MConsole::OnSayCommand_Pre(void *pUnknown, const CCommand &command){
	if(strcmp(command.Arg(0), "say") != 0 && strcmp(command.Arg(0), "say_team")){
		return;
	}

	int client = g_MConsole->cmdClient;
	auto player = playerhelpers->GetGamePlayer(client);


	if(client == 0 || player == NULL) RETURN_META(MRES_IGNORED);
	if(!player->IsConnected()) RETURN_META(MRES_IGNORED);


	const char *argsTmp = command.ArgS();
	if(argsTmp == NULL) RETURN_META(MRES_IGNORED);

	char *args = (char*) alloca(strlen(argsTmp) + 1);
	strcpy(args, argsTmp);

	// Remove quotes
	if(args[0] == '"' && strlen(args) > 2){
		args = &args[1];
		int len = strlen(args);
		if(args[len - 1] == '"') args[len - 1] = '\0';
	}

	

	bool isTrigger = false;
	bool isSilent = false;

	if(args[0] == '-'){
		isTrigger = true;
	}else if(args[0] == '/'){
		isTrigger = true;
		isSilent = true;
	}

	// Args: ["say" "-command" "arg1" "arg2"]

	if(isTrigger){
		args = &args[1]; // Skip the - or /

		int MAX_ARGS = 16;
		char **argArray = new char*[MAX_ARGS];
		int numArgs = 1;
		int curArgPos = 0;

		argArray[0] = new char[256];
		argArray[0][0] = '\0';
		int len = strlen(args);
		bool inQuotes = false;
		bool quotesType = -1;
		for(int i = 0; i < len; ++i){
			if(quotesType == 0 && args[i] == '"'){
				inQuotes = false;
			}else if(quotesType == 1 && args[i] == '\''){
				inQuotes = false;
			}else if(args[i] == '"'){
				inQuotes = true;
				quotesType = 0;
			}else if(args[i] == '\''){
				inQuotes = true;
				quotesType = 1;
			}else if(args[i] == ' ' && !inQuotes && numArgs < MAX_ARGS){
				argArray[numArgs - 1][curArgPos] = '\0';
				++numArgs;

				argArray[numArgs - 1] = new char[256];
				argArray[numArgs - 1][curArgPos] = '\0';
				curArgPos = 0;
			}else{
				argArray[numArgs - 1][curArgPos++] = args[i];
			}
		}

		argArray[numArgs - 1][curArgPos] = '\0';

		if(g_MConsole->InvokePluginsCommand(client, curArgPos == 0 ? numArgs - 1 : numArgs, (const char **) argArray, args) && isSilent){
			for(int i = 0; i < numArgs; ++i) delete[] argArray[i];
			delete[] argArray;
			RETURN_META(MRES_SUPERCEDE);
		}

		for(int i = 0; i < numArgs; ++i) delete[] argArray[i];
		delete[] argArray;
	}
}
예제 #30
0
void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command)
{
#elif SOURCE_ENGINE >= SE_ORANGEBOX
void CmdChangeLevelCallback(const CCommand &command)
{
#else
void CmdChangeLevelCallback()
{
	CCommand command;
#endif

	if (command.ArgC() < 2)
	{
		return;
	}

	if (g_NextMap.m_tempChangeInfo.m_mapName[0] == '\0')
	{
		ke::SafeSprintf(g_NextMap.m_tempChangeInfo.m_mapName, sizeof(g_NextMap.m_tempChangeInfo.m_mapName), command.Arg(1));
		ke::SafeSprintf(g_NextMap.m_tempChangeInfo.m_changeReason, sizeof(g_NextMap.m_tempChangeInfo.m_changeReason), "changelevel Command");
	}
}