Exemplo n.º 1
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" );
	}
}
//------------------------------------------------------------------------------
// Applies keyvalues to the entity by hammer ID.
//------------------------------------------------------------------------------
void CC_Ent_Keyvalue( const CCommand &args )
{
	// Must have an odd number of arguments.
	if ( ( args.ArgC() < 4 ) || ( args.ArgC() & 1 ) )
	{
		Msg( "Format: ent_keyvalue <entity id> \"key1\" \"value1\" \"key2\" \"value2\" ... \"keyN\" \"valueN\"\n" );
		return;
	}

	CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );
	CBaseEntity *pEnt;
	if ( FStrEq( args[1], "" ) || FStrEq( args[1], "!picker" ) )
	{
		if (!pPlayer)
			return;

		extern CBaseEntity *FindPickerEntity( CBasePlayer *pPlayer );
		pEnt = FindPickerEntity( pPlayer );

		if ( !pEnt )
		{
			ClientPrint( pPlayer, HUD_PRINTCONSOLE, "No entity in front of player.\n" );
			return;
		}
	}
	else if ( FStrEq( args[1], "!self" ) || FStrEq( args[1], "!caller" ) || FStrEq( args[1], "!activator" ) )
	{
		if (!pPlayer)
			return;

		pEnt = pPlayer;
	}
	else
	{
		int nID = atoi( args[1] );

		pEnt = g_ServerTools.FindEntityByHammerID( nID );
		if ( !pEnt )
		{
			Msg( "Entity ID %d not found.\n", nID );
			return;
		}
	}

	int nArg = 2;
	while ( nArg < args.ArgC() )
	{
		const char *pszKey = args[ nArg ];
		const char *pszValue = args[ nArg + 1 ];
		nArg += 2;

		g_ServerTools.SetKeyValue( pEnt, pszKey, pszValue );
	}
} 
Exemplo n.º 3
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);
    }
  }
}
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" );
	}
}
Exemplo n.º 5
0
// con command for loading a savegame
void ASW_LoadCampaignGame_cc( const CCommand &args )
{
	if ( args.ArgC() < 3 )
	{
		Msg("Usage: ASW_LoadCampaign [SaveName] [SP|MP]\n" );
		return;
	}

	// Use an arg to detect MP (would be better to check maxplayers here, but we can't?)
	bool bMulti = (!Q_strnicmp( args[2], "MP", 2 ));
	ASW_LaunchSaveGame(args[1], bMulti, args.ArgC() == 4);	// if 2nd parameter specified, do a changelevel instead of launching a new
}
Exemplo n.º 6
0
object execute_server_command(tuple args, dict kwargs)
{
	std::string szCommand;
	ConCommand* pCommand;
	prepare_command(args, kwargs, &pCommand, &szCommand);

	CCommand c;
	if (!c.Tokenize(szCommand.c_str()))
		BOOST_RAISE_EXCEPTION(PyExc_ValueError, "Failed to tokenize '%s'.", szCommand.c_str())

	pCommand->Dispatch(c);
	return object();
}
Exemplo n.º 7
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;
	}
}
Exemplo n.º 8
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;
}
Exemplo n.º 9
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));
}
Exemplo n.º 10
0
//-----------------------------------------------------------------------------
// Purpose: Create a new Bot and put it in the game.
// Output : Pointer to the new Bot, or NULL if there's no free clients.
//-----------------------------------------------------------------------------
CBasePlayer *BotPutInServer( bool bFrozen )
{
	char botname[ 64 ];
	Q_snprintf( botname, sizeof( botname ), "Bot%02i", g_CurBotNumber );

	
	// This trick lets us create a CSDKBot for this client instead of the CSDKPlayer
	// that we would normally get when ClientPutInServer is called.
	ClientPutInServerOverride( &CBotManager::ClientPutInServerOverride_Bot );
	edict_t *pEdict = engine->CreateFakeClient( botname );
	ClientPutInServerOverride( NULL );

	if (!pEdict)
	{
		Msg( "Failed to create Bot.\n");
		return NULL;
	}

	// Allocate a player entity for the bot, and call spawn
	CSDKBot *pPlayer = ((CSDKBot*)CBaseEntity::Instance( pEdict ));

	pPlayer->ClearFlags();
	pPlayer->AddFlag( FL_CLIENT | FL_FAKECLIENT );

	if ( bFrozen )
		pPlayer->AddEFlags( EFL_BOT_FROZEN );

	pPlayer->ChangeTeam( TEAM_UNASSIGNED );
	pPlayer->RemoveAllItems( true );

	SDKWeaponID eWeapon = SDK_WEAPON_NONE;
	
	while (eWeapon == SDK_WEAPON_NONE || eWeapon == SDK_WEAPON_BRAWL)
		eWeapon = (SDKWeaponID)RandomInt(1, WEAPON_MAX-1);

	pPlayer->AddToLoadout(eWeapon);

	pPlayer->State_Transition( STATE_ACTIVE );

	CCommand args;

	args.Tokenize( "menuclosed" );
	pPlayer->ClientCommand( args );

	g_CurBotNumber++;

	return pPlayer;
}
Exemplo n.º 11
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CommentaryShowModelViewer( const CCommand &args )
{
	if ( args.ArgC() < 2 )
	{
		ConMsg( "Usage: commentary_showmodelviewer <model name> <optional attached model name>\n" );
		return;
	}

	CBaseViewport *pViewport = dynamic_cast<CBaseViewport *>( GetClientMode()->GetViewport() );
	if ( pViewport )
	{
		IViewPortPanel *pCommentaryPanel = pViewport->FindPanelByName( PANEL_COMMENTARY_MODELVIEWER );
		if ( !pCommentaryPanel )
		{
			pCommentaryPanel = pViewport->CreatePanelByName( PANEL_COMMENTARY_MODELVIEWER );
			pViewport->AddNewPanel( pCommentaryPanel, "PANEL_COMMENTARY_MODELVIEWER" );
		}

		if ( pCommentaryPanel )
		{
			//((CCommentaryModelViewer*)pCommentaryPanel)->InvalidateLayout( false, true );
			((CCommentaryModelViewer*)pCommentaryPanel)->SetModel( args[1], args[2] );
			pViewport->ShowPanel( pCommentaryPanel, true );
		}
	}
}
Exemplo n.º 12
0
void ASW_TestRoute_cc(const CCommand &args)
{
	if ( args.ArgC() < 3 )
	{
		Warning( "Usage: ASW_TestRoute [start mission index] [end mission index]\n" );
		return;
	}
	if (!ASWGameRules() || !ASWGameRules()->GetCampaignSave())
	{
		Msg("Must be playing a campaign game!\n");
		return;
	}
	int iStart = atoi(args[1]);
	int iEnd = atoi(args[2]);
	CASW_Campaign_Save* pSave = ASWGameRules()->GetCampaignSave();
	bool bFound = pSave->BuildCampaignRoute(iStart, iEnd);
	if (bFound)
	{		
		Msg("Found route:\n");
		pSave->DebugBuiltRoute();
	}
	else
	{
		Msg("No route found!\n");
	}
}
Exemplo n.º 13
0
//---------------------------------------------------------------------------------
// Purpose: called when a client types in a command (only a subset of commands however, not CON_COMMAND's)
//---------------------------------------------------------------------------------
PLUGIN_RESULT CNoCheatZPlugin::ClientCommand( edict_t *pEntity, const CCommand &args )
{
	Msg("ClientCommand(%x, %s)\n", pEntity, args.GetCommandString());
	
	if ( !pEntity || pEntity->IsFree() ) 
	{
		return PLUGIN_CONTINUE;
	}

	NczPlayer* myPlayer = NczPlayerManager::GetInstance()->GetPlayerHandlerByEdict(pEntity)->playerClass;
	/*ActionID result = HashTable::GetInstance()->ScanCommandString(args.GetCommandString());
	if(result > SAFE)
	{
		if(result == BAN)
		{
			myPlayer->Ban();
		}
		if(result == KICK)
		{
			myPlayer->Kick();
		}
		return PLUGIN_STOP;
	}*/

	return PLUGIN_CONTINUE;
}
Exemplo n.º 14
0
static void change_portalgun_linkage_id_f( const CCommand &args )
{
	if( sv_cheats->GetBool() == false ) //heavy handed version since setting the concommand with FCVAR_CHEATS isn't working like I thought
		return;

	if( args.ArgC() < 2 )
		return;

	unsigned char iNewID = (unsigned char)atoi( args[1] );

	CPortal_Player *pPlayer = (CPortal_Player *)UTIL_GetCommandClient();

	int iWeaponCount = pPlayer->WeaponCount();
	for( int i = 0; i != iWeaponCount; ++i )
	{
		CBaseCombatWeapon *pWeapon = pPlayer->GetWeapon(i);
		if( pWeapon == NULL )
			continue;

		if( dynamic_cast<CWeaponPortalgun *>(pWeapon) != NULL )
		{
			CWeaponPortalgun *pPortalGun = (CWeaponPortalgun *)pWeapon;
			pPortalGun->m_iPortalLinkageGroupID = iNewID;
			break;
		}
	}
}
Exemplo n.º 15
0
	void DumpAchievementCounters( const CCommand &args )
	{
		int iPlayerIndex = 1;

		if ( args.ArgC() >= 2 )
		{
			iPlayerIndex = atoi( args[1] );
		}

		CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( UTIL_PlayerByIndex( iPlayerIndex ) );
		if ( pPlayer && pPlayer->GetPerLifeCounterKeys() )
		{
			CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
			pPlayer->GetPerLifeCounterKeys()->RecursiveSaveToFile( buf, 0 );

			char szBuf[1024];

			// probably not the best way to print out a CUtlBuffer
			int pos = 0;
			while ( buf.PeekStringLength() )
			{
				szBuf[pos] = buf.GetChar();
				pos++;
			}
			szBuf[pos] = '\0';

			Msg( "%s\n", szBuf );
		}
	}
Exemplo n.º 16
0
void asw_marine_spectate_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( args.ArgC() < 2 )
	{
		Msg( "Usage: asw_marine_spectate [marine_num]\n" );
		return;
	}

	CASW_Game_Resource* pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	int iMarine = atof(args[1]);
	if (iMarine < 0 || iMarine >= pGameResource->GetMaxMarineResources())
		return;

	CASW_Marine_Resource* pMR = pGameResource->GetMarineResource(iMarine);
	if (!pMR)
	{
		Msg("No marine resource in that index\n");
		return;
	}

	CASW_Marine *pMarine = pMR->GetMarineEntity();
	if (!pMarine)
	{
		Msg("No live marine in that slot\n");
		return;
	}
		
	pPlayer->SetSpectatingMarine(pMarine);
}
Exemplo n.º 17
0
//-----------------------------------------------------------------------------
// Purpose: TF2 Specific Client Commands
// Input  :
// Output :
//-----------------------------------------------------------------------------
bool CSDKGameRules::ClientCommand( CBaseEntity *pEdict, const CCommand &args )
{
	CSDKPlayer *pPlayer = ToSDKPlayer( pEdict );
#if 0
	const char *pcmd = args[0];
	if ( FStrEq( pcmd, "somecommand" ) )
	{
		if ( args.ArgC() < 2 )
			return true;

		// Do something here!

		return true;
	}
	else 
#endif
	// Handle some player commands here as they relate more directly to gamerules state
	if ( pPlayer->ClientCommand( args ) )
	{
		return true;
	}
	else if ( BaseClass::ClientCommand( pEdict, args ) )
	{
		return true;
	}
	return false;
}
Exemplo n.º 18
0
bool CScenePlay::SequenceMain(CCommand &command)
{
	CVector3 pos = Player->getCamera()->getEye();
	TimeupLogo->Position = CVector3(pos.x * 1.5f, pos.y, pos.z * 1.5f);
	TimeupLogo->qRotation = Player->getFrontRotation();
	
	// ゲームオブジェクト更新
	updateObjects();
	// UIの更新
	updateUI();
	// ランダムな生成
	PopObjectRandom();
	if(command.Check(CCommand::START))
		CSceneManager::Pause_();
	// ポーズ画像の描画
	PauseImage->isRender = (CSceneManager::getisPause_()) ? true : false;		

	if(CSceneManager::getisPause_())
		SequenceState = SEQ_PAUSE;

	if(TimeLimit <= 0)
	{
		CSceneManager::LockKey();
		Direct = Normalize(CVector3((TimeupLogo->Position - Player->Transform.Position).x, 0, (TimeupLogo->Position - Player->Transform.Position).z));
		TimeupLogo->isRender = true;
		SequenceState = SEQ_END;
	}

	Count++;

	// 正常動作
	return false;
}
Exemplo n.º 19
0
void CC_Mom_ZoneDelete(const CCommand &args)
{
    if (!mom_zone_edit.GetBool()) return;


    if (args.ArgC() > 1)
    {
        DevMsg("Attempting to delete '%s'\n", args[1]);

        int entindex = atoi(args[1]);

        if (entindex != 0)
        {
            CBaseEntity *pEnt = CBaseEntity::Instance(INDEXENT(entindex));

            if (pEnt && g_MapzoneEdit.GetEntityZoneType(pEnt) != -1)
            {
                UTIL_Remove(pEnt);
            }
        }
        else
        {
            char szDelete[64];
            if (ZoneTypeToClass(g_MapzoneEdit.ShortNameToZoneType(args[1]), szDelete))
            {
                CBaseEntity *pEnt = gEntList.FindEntityByClassname(NULL, szDelete);
                while (pEnt)
                {
                    UTIL_Remove(pEnt);
                    pEnt = gEntList.FindEntityByClassname(pEnt, szDelete);
                }
            }
        }
    }
}
void CC_ASW_Launch_Vote_Chooser( const CCommand &args )
{
    if ( args.ArgC() < 2 )
    {
        Msg("Usage: asw_vote_chooser [chooser type]");
        return;
    }
    int iChooserType = atoi(args[1]);
    if ( iChooserType < -1 || iChooserType > 2 )
        return;

    // if third param is specified, we assume it's the 'notrans' one
    bool bAvoidTranslucency =(args.ArgC() >= 3);

    LaunchMissionVotePanel(iChooserType, bAvoidTranslucency);
}
Exemplo n.º 21
0
void Test_SpawnRandomEntities( const CCommand &args )
{
	if ( args.ArgC() < 3 )
	{
		Error( "Test_SpawnRandomEntities <min # entities> <max # entities> missing arguments." );
	}

	if ( g_StressEntities.Count() == 0 )
	{
		Error( "Test_SpawnRandomEntities: not initialized (call Test_InitRandomEntitySpawner frst)." );
	} 

	int nMin = atoi( args[ 1 ] );
	int nMax = atoi( args[ 2 ] );
	int count = RandomInt( nMin, nMax );

	for ( int i=0; i < count; i++ )
	{
		int iSlot = RandomInt( 0, g_StressEntities.Count() - 1 );

		// Remove any old entity in this slot.
		if ( g_StressEntities[iSlot].Get() )
			UTIL_RemoveImmediate( g_StressEntities[iSlot] );

		// Create a new one in this slot.
		int iType = RandomInt( 0, g_StressEntityRegs.Count() - 1 );
		g_StressEntities[iSlot] = g_StressEntityRegs[iType]->GetFn()();
	}
}
Exemplo n.º 22
0
bool CHL2MP_Player::ClientCommand( const CCommand &args )
{
	if ( FStrEq( args[0], "spectate" ) )
	{
		if ( ShouldRunRateLimitedCommand( args ) )
		{
			// instantly join spectators
			HandleCommand_JoinTeam( TEAM_SPECTATOR );	
		}
		return true;
	}
	else if ( FStrEq( args[0], "jointeam" ) ) 
	{
		if ( args.ArgC() < 2 )
		{
			Warning( "Player sent bad jointeam syntax\n" );
		}

		if ( ShouldRunRateLimitedCommand( args ) )
		{
			int iTeam = atoi( args[1] );
			HandleCommand_JoinTeam( iTeam );
		}
		return true;
	}
	else if ( FStrEq( args[0], "joingame" ) )
	{
		return true;
	}

	return BaseClass::ClientCommand( args );
}
Exemplo n.º 23
0
void asw_carnage_f(const CCommand &args)
{
	if ( args.ArgC() < 2 )
	{
		Msg( "Please supply a scale\n" );
	}
	ASW_ApplyCarnage_f( atof( args[1] ) );
}
Exemplo n.º 24
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;
		}

		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());
	}
}
Exemplo n.º 25
0
void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args)
{
#else
void PlayerManager::OnClientCommand(edict_t *pEntity)
{
	CCommand args;
#endif
	int client = engine->IndexOfEdict(pEntity);
	cell_t res = Pl_Continue;
	CPlayer *pPlayer = &m_Players[client];

	if (!pPlayer->IsConnected())
	{
		return;
	}

	g_HL2.PushCommandStack(&args);

	int argcount = args.ArgC() - 1;
	const char *cmd = g_HL2.CurrentCommandName();

	bool result = g_ValveMenuStyle.OnClientCommand(client, cmd, args);
	if (result)
	{
		res = Pl_Handled;
	} else {
		result = g_RadioMenuStyle.OnClientCommand(client, cmd, args);
		if (result)
		{
			res = Pl_Handled;
		}
	}

	cell_t res2 = Pl_Continue;
	m_clcommand->PushCell(client);
	m_clcommand->PushCell(argcount);
	m_clcommand->Execute(&res2, NULL);

	if (res2 > res)
	{
		res = res2;
	}

	if (res >= Pl_Stop)
	{
		g_HL2.PopCommandStack();
		RETURN_META(MRES_SUPERCEDE);
	}

	res = g_ConCmds.DispatchClientCommand(client, cmd, argcount, (ResultType)res);

	g_HL2.PopCommandStack();

	if (res >= Pl_Handled)
	{
		RETURN_META(MRES_SUPERCEDE);
	}
}
Exemplo n.º 26
0
bool CVoiceGameMgr::ClientCommand( CBasePlayer *pPlayer, const CCommand &args )
{
	int playerClientIndex = pPlayer->entindex() - 1;
	if(playerClientIndex < 0 || playerClientIndex >= m_nMaxPlayers)
	{
		VoiceServerDebug( "CVoiceGameMgr::ClientCommand: cmd %s from invalid client (%d)\n", args[0], playerClientIndex );
		return true;
	}

	bool bBan = stricmp( args[0], "vban" ) == 0;
	if( bBan && args.ArgC() >= 2 )
	{
		for(int i=1; i < args.ArgC(); i++)
		{
			unsigned long mask = 0;
			sscanf( args[i], "%p", (void**)&mask);

			if( i <= VOICE_MAX_PLAYERS_DW )
			{
				VoiceServerDebug( "CVoiceGameMgr::ClientCommand: vban (0x%x) from %d\n", mask, playerClientIndex );
				g_BanMasks[playerClientIndex].SetDWord(i-1, mask);
			}
			else
			{
				VoiceServerDebug( "CVoiceGameMgr::ClientCommand: invalid index (%d)\n", i );
			}
		}

		// Force it to update the masks now.
		//UpdateMasks();		
		return true;
	}
	else if(stricmp( args[0], "VModEnable") == 0 && args.ArgC() >= 2)
	{
		VoiceServerDebug( "CVoiceGameMgr::ClientCommand: VModEnable (%d)\n", !!atoi( args[1] ) );
		g_PlayerModEnable[playerClientIndex] = !!atoi( args[1] );
		g_bWantModEnable[playerClientIndex] = false;
		//UpdateMasks();		
		return true;
	}
	else
	{
		return false;
	}
}
Exemplo n.º 27
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");
	}
}
Exemplo n.º 28
0
void Test_ProxyToggle_EnableProxy( const CCommand &args )
{
	if ( args.ArgC() < 2 )
	{
		Error( "Test_ProxyToggle_EnableProxy: requires parameter (0 or 1)." );
	}

	g_bEnableProxy = !!atoi( args[ 1 ] );
}
Exemplo n.º 29
0
void CCommand::Run(tstring sCommand)
{
	tvector<tstring> asTokens;
	tstrtok(sCommand, asTokens);

	if (asTokens.size() == 0)
		return;

	tmap<tstring, CCommand*>::iterator it = GetCommands().find(asTokens[0]);
	if (it == GetCommands().end())
	{
		TMsg("Unrecognized command.\n");
		return;
	}

	CCommand* pCommand = it->second;
	pCommand->m_pfnCallback(pCommand, asTokens, sCommand);
}
Exemplo n.º 30
0
static void ForwardSpecCmdToServer( const CCommand &args )
{
	if ( engine->IsPlayingDemo() )
		return;

	if ( args.ArgC() == 1 )
	{
		// just forward the command without parameters
		engine->ServerCmd( args[ 0 ] );
	}
	else if ( args.ArgC() == 2 )
	{
		// forward the command with parameter
		char command[128];
		Q_snprintf( command, sizeof(command), "%s \"%s\"", args[ 0 ], args[ 1 ] );
		engine->ServerCmd( command );
	}
}