Example #1
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 );
		}
	}
}
Example #2
0
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);
    }
  }
}
Example #3
0
	bool CMultiplayRules::ClientCommand( CBaseEntity *pEdict, const CCommand &args )
	{
		CBasePlayer *pPlayer = ToBasePlayer( pEdict );

		const char *pcmd = args[0];
		if ( FStrEq( pcmd, "voicemenu" ) )
		{
			if ( args.ArgC() < 3 )
				return true;

			CBaseMultiplayerPlayer *pMultiPlayerPlayer = dynamic_cast< CBaseMultiplayerPlayer * >( pPlayer );

			if ( pMultiPlayerPlayer )
			{
				int iMenu = atoi( args[1] );
				int iItem = atoi( args[2] );

				VoiceCommand( pMultiPlayerPlayer, iMenu, iItem );
			}

			return true;
		}
		else if ( FStrEq( pcmd, "achievement_earned" ) )
		{
			CBaseMultiplayerPlayer *pPlayer = static_cast<CBaseMultiplayerPlayer*>( pEdict );
			if ( pPlayer && pPlayer->ShouldAnnounceAchievement() )
			{
				// let's check this came from the client .dll and not the console
				unsigned short mask = UTIL_GetAchievementEventMask();
				int iPlayerID = pPlayer->GetUserID();

				int iAchievement = atoi( args[1] ) ^ mask;
				int code = ( iPlayerID ^ iAchievement ) ^ mask;

				if ( code == atoi( args[2] ) )
				{
					IGameEvent * event = gameeventmanager->CreateEvent( "achievement_earned" );
					if ( event )
					{
						event->SetInt( "player", pEdict->entindex() );
						event->SetInt( "achievement", iAchievement );
						gameeventmanager->FireEvent( event );
					}

					pPlayer->OnAchievementEarned( iAchievement );
				}
			}

			return true;
		}

		return BaseClass::ClientCommand( pEdict, args );

	}
Example #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" );
	}
}
Example #5
0
void asw_alien_horde_f( const CCommand& args )
{
    if ( args.ArgC() < 2 )
    {
        Msg("supply horde size!\n");
        return;
    }
    if ( !ASWSpawnManager()->AddHorde( atoi(args[1]) ) )
    {
        Msg("Failed to add horde\n");
    }
}
void asw_minimap_scale_f( const CCommand &args )
{
	CASWHudMinimap *pMiniMap = GET_HUDELEMENT(CASWHudMinimap);
	if (!pMiniMap)
		return;

	if (args.ArgC() == 2)
	{		
		pMiniMap->m_fMapScale = atof( args[1] );
		Msg("Set minimap scale to %f\n", pMiniMap->m_fMapScale);
	}
}
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" );
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CC_DebugHistory_AddLine( const CCommand &args )
{
	if ( args.ArgC() < 3 )
	{
		Warning("Incorrect parameters. Format: <category id> <line>\n");
		return;
	}

	int iCategory = atoi(args[ 1 ]);
	const char *pszLine = args[ 2 ];
	AddDebugHistoryLine( iCategory, pszLine );
}
Example #9
0
/*
===================
SV_ValidateClientCommand

Determine if passed in user command is valid.
===================
*/
bool CGameClient::IsEngineClientCommand( const CCommand &args ) const
{
	if ( args.ArgC() == 0 )
		return false;

	for ( int i = 0; s_clcommands[i] != NULL; ++i )
	{
		if ( !Q_strcasecmp( args[0], s_clcommands[i] ) )
			return true;
	}

	return false;
}
void Test_ProxyToggle_SetValue( const CCommand &args )
{
	if ( args.ArgC() < 2 )
	{
		Error( "Test_ProxyToggle_SetValue: requires value parameter." );
	}
	else if ( !g_pTestObj )
	{
		Error( "Test_ProxyToggle_SetValue: no entity present." );
	}

	g_pTestObj->m_WithProxy = atoi( args[ 1 ] );
}
// con command for new campaign
void ASW_StartNewCampaign_cc( const CCommand &args )
{
	IASW_Mission_Chooser_Source* pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
	if (!pSource)
		return;

	if ( args.ArgC() < 4 )
	{
		Msg( "Usage: ASW_StartCampaign [CampaignName] [SaveName] [SP|MP]\n   Use 'auto' for SaveName to have an autonumbered save.\n" );
		return;
	}

	// create a new savegame at the start of the campaign
	char buffer[256];
	if (!Q_strnicmp( args[2], "auto", 4 ))
	{
		const char *pNewSaveName = GenerateNewSaveGameName();
		if (!pNewSaveName)
		{
			Msg("Error! No more room for autogenerated save names, delete some save games!\n");
			return;
		}
		Q_snprintf(buffer, sizeof(buffer), "%s", pNewSaveName);
	}
	else
		Q_snprintf(buffer, sizeof(buffer), "%s", args[2]);

	// Use an arg to detect MP (would be better to check maxplayers here, but we can't?)
	bool bMulti = (!Q_strnicmp( args[3], "MP", 2 ));
	if (!pSource->ASW_Campaign_CreateNewSaveGame(&buffer[0], sizeof(buffer), args[1], bMulti, NULL))
	{
		Msg( "Unable to create new save game.\n" );
		return;
	}

	// go to the load savegame code
	ASW_LaunchSaveGame(buffer, bMulti, args.ArgC() == 5);	// if 3rd parameter specified, do a changelevel instead of launching a new
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CC_DebugHistory_Dump( const CCommand &args )
{
	if ( args.ArgC() < 2 )
	{
		Warning("Incorrect parameters. Format: <category id>\n");
		return;
	}

	if ( GetDebugHistory() )
	{
		int iCategory = atoi(args[ 1 ]);
		GetDebugHistory()->DumpDebugHistory( iCategory );
	}
}
Example #13
0
static void GetPos( const CCommand &args, Vector &vecOrigin, QAngle &angles )
{
	vecOrigin = MainViewOrigin();
	angles = MainViewAngles();
	if ( args.ArgC() == 2 && atoi( args[1] ) == 2 )
	{
		C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
		if ( pPlayer )
		{
			vecOrigin = pPlayer->GetAbsOrigin();
			angles = pPlayer->GetAbsAngles();
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: Handle custom commands for this playerclass
//-----------------------------------------------------------------------------
bool CPlayerClass::ClientCommand( const CCommand& args )
{
	if ( FStrEq( args[0], "builder_select_obj" ) )
	{
		if ( args.ArgC() < 2 )
			return true;

		// This is a total hack. Eventually this should come in via usercmds.

		// Get our builder weapon
		if ( !m_pPlayer->GetWeaponBuilder() )
			return true;

		// Select a state for the builder weapon
		m_pPlayer->GetWeaponBuilder()->SetCurrentObject( atoi( args[1] ) );
		m_pPlayer->GetWeaponBuilder()->SetCurrentState( BS_PLACING );
		m_pPlayer->GetWeaponBuilder()->StartPlacement(); 
		m_pPlayer->GetWeaponBuilder()->m_flNextPrimaryAttack = gpGlobals->curtime + 0.35f;
		return true;
	}
	else if ( FStrEq( args[0], "builder_select_mode" ) )
	{
		if ( args.ArgC() < 2 )
			return true;

		// Get our builder weapon
		if ( !m_pPlayer->GetWeaponBuilder() )
			return true;

		// Select a state for the builder weapon
		m_pPlayer->GetWeaponBuilder()->SetCurrentState( atoi( args[1] ) );
		m_pPlayer->GetWeaponBuilder()->m_flNextPrimaryAttack = gpGlobals->curtime + 0.35f;
		return true;
	}

	return false;
}
Example #15
0
bool CGameClient::ExecuteStringCommand( const char *pCommandString )
{
	// first let the baseclass handle it
	if ( CBaseClient::ExecuteStringCommand( pCommandString ) )
		return true;
	
	// Determine whether the command is appropriate
	CCommand args;
	if ( !args.Tokenize( pCommandString ) )
		return false;

	if ( args.ArgC() == 0 )
		return false;

	if ( IsEngineClientCommand( args ) )
	{
		Cmd_ExecuteCommand( args, src_client, m_nClientSlot );
		return true;
	}
	
	const ConCommandBase *pCommand = g_pCVar->FindCommandBase( args[ 0 ] );
	if ( pCommand && pCommand->IsCommand() && pCommand->IsFlagSet( FCVAR_GAMEDLL ) )
	{
		// Allow cheat commands in singleplayer, debug, or multiplayer with sv_cheats on
		// NOTE: Don't bother with rpt stuff; commands that matter there shouldn't have FCVAR_GAMEDLL set
		if ( pCommand->IsFlagSet( FCVAR_CHEAT ) )
		{
			if ( sv.IsMultiplayer() && !CanCheat() )
				return false;
		}

		if ( pCommand->IsFlagSet( FCVAR_SPONLY ) )
		{
			if ( sv.IsMultiplayer() )
			{
				return false;
			}
		}

		g_pServerPluginHandler->SetCommandClient( m_nClientSlot );
		Cmd_Dispatch( pCommand, args );
	}
	else
	{
		g_pServerPluginHandler->ClientCommand( edict, args ); // TODO pass client id and string
	}

	return true;
}
//------------------------------------------------------------------------------
// Purpose: Teleport a specified entity to where the player is looking
//------------------------------------------------------------------------------
void CC_ASW_Ent_Teleport( const CCommand& args )
{
	if ( args.ArgC() < 2 )
	{
		Msg( "Format: ent_teleport <entity name>\n" );
		return;
	}

	CBaseEntity *pEnt;
	Vector vecTargetPoint;
	if ( CC_ASW_GetCommandEnt( args, &pEnt, &vecTargetPoint, NULL ) )
	{
		pEnt->Teleport( &vecTargetPoint, NULL, NULL );
	}
}
Example #17
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));
}
Example #18
0
void ASW_TestLoad_cc(const CCommand &args)
{
	if ( args.ArgC() < 2 )
	{
		Warning( "You must specify the name of the saved campaign game to resume playing.\n" );
		return;
	}
	CASW_Campaign_Save *pSave = new CASW_Campaign_Save();
	if (!pSave->LoadGameFromFile(args[1]))
	{
		Msg("LoadGameFromFile failed!\n");
	}
	else
		pSave->DebugInfo();
}
void asw_spawn_alien_f(const CCommand &args)
{
	if ( args.ArgC() < 2 )
	{
		Msg( "Please supply a spawner name\n" );
	}
	CBaseEntity* pEntity = NULL;
	while ((pEntity = gEntList.FindEntityByClassname( pEntity, "asw_spawner" )) != NULL)
	{
		CASW_Spawner* pSpawner = dynamic_cast<CASW_Spawner*>(pEntity);
		if (pSpawner && !stricmp(STRING(pSpawner->GetEntityName()), args[1]))
		{
			pSpawner->SpawnOneAlien();
		}
	}
}
void asw_test_marinenearby_f(const CCommand &args)
{
	Msg("0.5 as float = %f\n", 0.5f);
	Msg("0.5f as int = %d\n", (int) 0.5f);
	Msg("0.51f as int = %d\n", (int) 0.51f);
	Msg("0.52f as int = %d\n", (int) 0.52f);
	Msg("0.6f as int = %d\n", (int) 0.6f);
	Msg("0.56f as int = %d\n", (int) 0.56f);
	Msg("0.49f as int = %d\n", (int) 0.49f);
	Msg("1.99f as int = %d\n", (int) 1.99f);
	Msg("2.01f as int = %d\n", (int) 2.01f);
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());	

	if (!ASWGameRules())
		return;
	if (!pPlayer || !pPlayer->GetMarine())
		return;
	
	if ( args.ArgC() < 4 )
	{
		Msg("Usage: asw_test_marinenearby [0|1] [grid step] [grid count]\n");
	}
	int iWide = atoi(args[1]);
	float fGridStep = atof(args[2]);
	int iGridCount = atoi(args[3]);
	//Msg("Wide = %d, step = %f, count = %d\n", iWide, fGridStep, iGridCount);

	Vector asw_default_camera_dir_2;
	QAngle test_angle(asw_marine_nearby_angle.GetFloat(), 90, 0);
	AngleVectors(test_angle, &asw_default_camera_dir_2);
	Vector asw_default_camera_offset_2 = asw_default_camera_dir_2 * -405.0f;

	for (int x=-iGridCount;x<iGridCount;x++)
	{
		for (int y=-iGridCount;y<iGridCount*3;y++)
		{
			Vector pos = pPlayer->GetMarine()->GetAbsOrigin() + Vector(x * fGridStep, y*fGridStep, 10);
			//Msg("Testing pos %f, %f, %f\n", pos.x, pos.y, pos.z);
			bool bCorpseCanSee = false;
			UTIL_ASW_AnyMarineCanSee(pos,
				iWide, bCorpseCanSee);
		}
	}	
	Vector pos = (pPlayer->GetMarine()->GetAbsOrigin() + asw_default_camera_offset_2);
	//NDebugOverlay::Line(pos, pos + asw_default_camera_dir_2 * 410, 0,0,255,true, 30);
}
Example #21
0
void Test_InitRandomEntitySpawner( const CCommand &args )
{
	// Put the list of registered functions into array form for convenience.
	g_StressEntityRegs.Purge();
	for ( CStressEntityReg *pCur=CStressEntityReg::GetListHead(); pCur; pCur=pCur->GetNext() )
		g_StressEntityRegs.AddToTail( pCur );

	// Create slots for all the entities..
	int nSlots = 100;
	if ( args.ArgC() >= 2 )
		nSlots = atoi( args[ 1 ] );

	g_StressEntities.Purge();
	g_StressEntities.SetSize( nSlots );

	Msg( "Test_InitRandomEntitySpawner: created %d slots.\n", nSlots );
}
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;
		}

		IRootConsoleCommand *pHandler;
		if (sm_trie_retrieve(m_pCommands, cmdname, (void **)&pHandler))
		{
			pHandler->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());
	}
}
void asw_conversation_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer)
		return;
	
	CASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;

	if (args.ArgC() < 2)
	{
		Msg("Usage: asw_conversation [conversation number]\n");
	}
	int iConv = atoi(args[1]);
	CASW_MarineSpeech::StartConversation(iConv, pMarine);
}
void CC_ASW_Main_Menu_Option( const CCommand &args )
{
    if ( args.ArgC() < 3 )
    {
        Msg("Usage: asw_main_menu_option [host type] [chooser type]");
        return;
    }
    int iHostType = atoi(args[1]);
    if (iHostType < 0 || iHostType > 2 )
        return;

    int iChooserType = atoi(args[2]);
    if (iChooserType < 0 || iChooserType > 2 )
        return;

    LaunchMissionChooser(iHostType, iChooserType);
}
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");
	}
}
// Console command for creating env_projectedtexture entities
void CC_CreateFlashlight( const CCommand &args )
{
    CBasePlayer *pPlayer = UTIL_GetCommandClient();
    if( !pPlayer )
        return;

    QAngle angles = pPlayer->EyeAngles();
    Vector origin = pPlayer->EyePosition();

    CEnvProjectedTexture *pFlashlight = dynamic_cast< CEnvProjectedTexture * >( CreateEntityByName("env_projectedtexture") );
    if( args.ArgC() > 1 )
    {
        pFlashlight->SetName( AllocPooledString( args[1] ) );
    }

    pFlashlight->Teleport( &origin, &angles, NULL );

}
void asw_set_solid_f( const CCommand &args )
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());

	if (pPlayer == NULL)
	{
		Msg("Couldn't find local player.");
		return;
	}
	if (args.ArgC() != 2)
		return;

	CASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;

	pMarine->SetSolid((SolidType_t) atoi(args[1]));
}
//=========================================================
// ClientCommand
// the user has typed a command which is unrecognized by everything else;
// this check to see if the gamerules knows anything about the command
//=========================================================
bool CTeamplayRules::ClientCommand( CBaseEntity *pEdict, const CCommand &args )
{
	if( BaseClass::ClientCommand( pEdict, args ) )
		return true;
	
	if ( FStrEq( args[0], "menuselect" ) )
	{
		if ( args.ArgC() < 2 )
			return true;

		//int slot = atoi( args[1] );

		// select the item from the current menu

		return true;
	}

	return false;
}
Example #29
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));
	}
}
Example #30
0
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");
	}
}