本文整理汇总了C++中APlayerController::ConsoleCommand方法的典型用法代码示例。如果您正苦于以下问题:C++ APlayerController::ConsoleCommand方法的具体用法?C++ APlayerController::ConsoleCommand怎么用?C++ APlayerController::ConsoleCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APlayerController
的用法示例。
在下文中一共展示了APlayerController::ConsoleCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConsoleCommand
void UConsole::ConsoleCommand(const FString& Command)
{
// insert into history buffer
{
HistoryBuffer.Add(Command);
NormalizeHistoryBuffer();
}
// Save the command history to the INI.
SaveConfig();
OutputText(FString::Printf(TEXT("\n>>> %s <<<"), *Command));
UWorld *World = GetOuterUGameViewportClient()->GetWorld();
if(ConsoleTargetPlayer != NULL)
{
// If there is a console target player, execute the command in the player's context.
ConsoleTargetPlayer->PlayerController->ConsoleCommand(Command);
}
else if(World && World->GetPlayerControllerIterator())
{
// If there are any players, execute the command in the first player's context that has a non-null Player.
for (auto PCIter = World->GetPlayerControllerIterator(); PCIter; ++PCIter)
{
APlayerController* PC = *PCIter;
if (PC && PC->Player)
{
PC->ConsoleCommand(Command);
break;
}
}
}
else
{
// Otherwise, execute the command in the context of the viewport.
GetOuterUGameViewportClient()->ConsoleCommand(Command);
}
}
示例2: Exec
//.........这里部分代码省略.........
LocalPC = MyWorld->GetGameInstance() ? MyWorld->GetGameInstance()->GetFirstLocalPlayerController() : nullptr;
}
}
if (LocalPC == nullptr)
{
return false;
}
if (MyWorld->GetNetMode() == NM_Client)
{
AGameplayDebuggingReplicator* Replicator = NULL;
for (TActorIterator<AGameplayDebuggingReplicator> It(MyWorld); It; ++It)
{
Replicator = *It;
if (Replicator && !Replicator->IsPendingKill())
{
APlayerController* PCOwner = Replicator->GetLocalPlayerOwner();
if (LocalPC == PCOwner)
{
break;
}
}
Replicator = NULL;
}
if (!Replicator)
{
LocalPC->ClientMessage(TEXT("Enabling GameplayDebugger on server, please wait for replicated data..."));
if (LocalPC->PlayerState)
{
const FString ServerCheatString = FString::Printf(TEXT("cheat EnableGDT %s"), *LocalPC->PlayerState->UniqueId.ToString());
UE_LOG(LogGameplayDebugger, Warning, TEXT("Sending to Server: %s"), *ServerCheatString);
LocalPC->ConsoleCommand(*ServerCheatString);
bHandled = true;
}
}
else
{
if (Replicator->IsToolCreated() == false)
{
Replicator->CreateTool();
}
Replicator->EnableTool();
bHandled = true;
}
}
else
{
UE_LOG(LogGameplayDebugger, Warning, TEXT("Got from client: EnableGDT %s"), *UniquePlayerId);
{
AGameplayDebuggingReplicator* Replicator = NULL;
for (TActorIterator<AGameplayDebuggingReplicator> It(MyWorld); It; ++It)
{
Replicator = *It;
if (Replicator && !Replicator->IsPendingKill())
{
APlayerController* PCOwner = Replicator->GetLocalPlayerOwner();
if (LocalPC == PCOwner)
{
break;
}
}
Replicator = NULL;
}