UGameplayStatics::GetIntOption
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticBlueprintPure
Description
Looks up a key in a URL options string and returns its value parsed as a 32-bit integer. Returns DefaultValue if the key is absent or the associated string cannot be converted to an integer.
Caveats & Gotchas
- • Non-numeric characters in the value string cause FCString::Atoi to silently return 0, which is then used as the parsed value — not DefaultValue. Validate the string with HasOption + ParseOption if you need to distinguish a malformed value from a missing key.
- • Unlike ParseOption this function takes Options by const reference, so no internal copy is made; it is slightly cheaper in tight loops.
Signature
static ENGINE_API int32 GetIntOption( const FString& Options, const FString& Key, int32 DefaultValue); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Options | const FString& | The full options string to search. | — |
| Key | const FString& | The key whose value should be parsed as an integer. | — |
| DefaultValue | int32 | Value to return if the key is not found or its value is not a valid integer. | — |
Return Type
int32 Example
Read player count from travel URL in GameMode::InitGame C++
void AMyGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
Super::InitGame(MapName, Options, ErrorMessage);
MaxPlayers = UGameplayStatics::GetIntOption(Options, TEXT("MaxPlayers"), 8);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?