PlayTimeLimit
PlayTimeLimit
#Overview
name: PlayTimeLimit
This variable is created as a Console Variable (cvar).
- type:
Exec
- help:
Sorry: Exec commands have no help
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of PlayTimeLimit is to implement and manage a system that limits the amount of time a user can play a game. This feature is often used for compliance with regulations or to promote healthy gaming habits, especially for younger players.
The PlayTimeLimit system is primarily implemented in the OnlineFramework plugin, specifically in the PlayTimeLimit module. Based on the callsites, we can see that it’s also integrated with the OnlineSubsystemTencent, suggesting it has specific implementations for different online subsystems.
The value of this variable (bPlayTimeLimitEnabled) is set in the engine configuration file (GEngineIni). It’s read during the startup of the PlayTimeLimitModule.
The bPlayTimeLimitEnabled variable interacts with other parts of the system, such as FPlayTimeLimitImpl. When enabled, it initializes the PlayTimeLimit implementation and allows various runtime commands to be executed.
Developers should be aware that:
- This system can be enabled or disabled through configuration.
- It provides runtime commands for debugging and testing, such as dumping state, forcing notifications, and setting user limits.
- It can interact with different online subsystems, as evidenced by the Tencent-specific implementation.
Best practices when using this variable include:
- Ensure it’s properly configured in the engine configuration file for the intended behavior.
- Use the provided runtime commands for testing and debugging.
- Implement appropriate user interfaces to inform players about their play time limits.
- Consider different online subsystem implementations when working with various platforms.
- Be mindful of regional regulations that may require specific play time limit implementations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/PlayTimeLimit/Private/PlayTimeLimitModule.cpp:8
Scope: file
Source code excerpt:
#include "Misc/ConfigCacheIni.h"
IMPLEMENT_MODULE(FPlayTimeLimitModule, PlayTimeLimit);
DEFINE_LOG_CATEGORY(LogPlayTimeLimit);
void FPlayTimeLimitModule::StartupModule()
{
GConfig->GetBool(TEXT("PlayTimeLimit"), TEXT("bEnabled"), bPlayTimeLimitEnabled, GEngineIni);
if (bPlayTimeLimitEnabled)
{
FPlayTimeLimitImpl::Get().Initialize();
}
}
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/PlayTimeLimit/Private/PlayTimeLimitModule.cpp:33
Scope (from outer to inner):
file
function bool FPlayTimeLimitModule::Exec_Runtime
Source code excerpt:
bool bWasHandled = false;
// Ignore any execs that don't start with PlayTimeLimit
if (FParse::Command(&Cmd, TEXT("PlayTimeLimit")))
{
if (bPlayTimeLimitEnabled)
{
bWasHandled = true; // Set to false in the catch-all else block
FPlayTimeLimitImpl& PlayTimeLimit = FPlayTimeLimitImpl::Get();
if (FParse::Command(&Cmd, TEXT("DUMP")))
{
PlayTimeLimit.DumpState();
}
else if (FParse::Command(&Cmd, TEXT("NOTIFYNOW")))
{
PlayTimeLimit.NotifyNow();
}
else if (FParse::Command(&Cmd, TEXT("SETUSERLIMITS")))
{
// Usage: SETUSERLIMITS <(optional) sub=(Online Subsystem Name)> <usernum> <has limit = [true, false]> <current play time limits>
// Ex: PLAYTIMELIMIT SETUSERLIMITS SUB=NULL 0 TRUE 60
// Ex: PLAYTIMELIMIT SETUSERLIMITS 0 FALSE
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/PlayTimeLimit/Private/PlayTimeLimitModule.cpp:89
Scope: file
Source code excerpt:
if (UserId.IsValid())
{
PlayTimeLimit.MockUser(*UserId, bHasLimit, CurrentPlayTimeMinutes);
}
else
{
UE_LOG(LogPlayTimeLimit, Warning, TEXT("SETUSERLIMITS: Could not get player id from user num=%d, ensure you are logged in first"), LocalUserNum);
}
}
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemTencent/Source/Private/OnlinePlayTimeLimitTencent.cpp:103
Scope (from outer to inner):
file
function void FOnlinePlayTimeLimitUserTencentRail::HandleAASDialog
Source code excerpt:
{
// RailSDK has told us that we should display an anti addiction message.
// Set time until next message to 0, and let the PlayTimeLimit system handle
// displaying the message.
double Now = FPlatformTime::Seconds();
OverrideDialogTitle = DialogTitle;
OverrideDialogText = DialogText;
OverrideButtonText = ButtonText;