RealDocs

AGameModeBase::AllowCheats

function Engine Since 4.14
#include "GameFramework/GameModeBase.h"
Access: public Specifiers: virtual

Description

Returns true if the given player should have access to cheat commands. The default implementation returns true only in non-shipping builds and when not running a network game. Override to restrict or expand cheat access for QA builds or admin accounts.

Caveats & Gotchas

  • In a networked game, the default implementation always returns false to prevent clients from using cheats on a dedicated server. If you override and return true in a multiplayer context, any connected client can execute cheat commands — never do this in production.
  • This is checked when a UCheatManager is first activated on the PlayerController. If cheats were already enabled before you change the return value, the existing CheatManager remains active — disabling cheats at runtime requires explicitly destroying the CheatManager.
  • The check runs server-side via the PlayerController's server cheat RPC. A client cannot directly call this function; it only matters on the server.

Signature

ENGINE_API virtual bool AllowCheats(APlayerController* P);

Parameters

Name Type Description Default
P APlayerController* The player controller requesting cheat access.

Return Type

bool

Example

Allow cheats for admin players in QA builds C++
bool AMyGameMode::AllowCheats(APlayerController* P)
{
#if !UE_BUILD_SHIPPING
    // Allow cheats for admin players in QA
    if (AMyPlayerState* PS = P ? Cast<AMyPlayerState>(P->PlayerState) : nullptr)
    {
        return PS->bIsAdmin;
    }
#endif
    return false;
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.