RealDocs

AGameModeBase::CanServerTravel

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

Description

Override to gate server travel to specific maps or under specific conditions. Returns true if the server is allowed to travel to the given URL.

Caveats & Gotchas

  • The base implementation performs security checks, including verifying the URL does not try to load paths outside the game content directory. Overriding without calling Super can expose a directory-traversal security vulnerability.
  • This is called only on the server. If you need to show a rejection message to players, you must handle that separately via RPC or game state — this function alone provides no client feedback.

Signature

ENGINE_API virtual bool CanServerTravel(const FString& URL, bool bAbsolute);

Parameters

Name Type Description Default
URL const FString& The destination map URL, optionally including game options.
bAbsolute bool If true, treats the URL as an absolute path; if false, treats it as relative to the current map.

Return Type

bool

Example

Restrict travel to an approved map allowlist C++
bool AMyGameMode::CanServerTravel(const FString& URL, bool bAbsolute)
{
	if (!Super::CanServerTravel(URL, bAbsolute))
	{
		return false;
	}
	const TArray<FString> AllowedMaps = { TEXT("/Game/Maps/Arena"), TEXT("/Game/Maps/Lobby") };
	for (const FString& Map : AllowedMaps)
	{
		if (URL.StartsWith(Map))
		{
			return true;
		}
	}
	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.