# Get the number of players from PIE?

**URL:** <https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [December 28, 2022, 10:27pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925 "2022-12-28T22:27:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghullie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ghullie/32/727344_2.png) [@Ghullie](https://forums.unrealengine.com/u/Ghullie)\
**Post date:** [December 28, 2022, 10:27pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/1 "2022-12-28T22:27:17Z")

</div>

Quick question, is there a way to access this Int with blueprints?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/9/c/89cb15fbc74cd542143910850b83050ed690f46b.png)

The rounds in my game start only when all players have loaded in from the lobby, when testing directly on the ingame map there is no loading, so I have to set the number manually, id be able to automate this if the Number of Players (opened clients) was accessible

Any help appreciated

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [December 29, 2022, 5:03pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/2 "2022-12-29T17:03:11Z")

</div>

in your GameMode exists an Event called

```auto
HandleStartingNewPlayer

```

This Event returns a PlayerController of the newly entered Player.  
add this Conzroller to an Array, so you have an Array of Player, that you can get the Length of, that is your current connected Player count.

---

<div class="post-metadata">

**Author:** ![Ghullie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ghullie/32/727344_2.png) [@Ghullie](https://forums.unrealengine.com/u/Ghullie)\
**Post date:** [December 29, 2022, 5:53pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/3 "2022-12-29T17:53:39Z")

</div>

Thanks for the suggestion, but its not fast enough. I use the Dev Authentication Tool to login to EOS before PIE launches which makes the clients login slower than the server, this causes them to be desynchronized in the beginning. I need the “number of expected players to join” from the get go.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/d/4/5d4923e88ddab2f36724bf3ce078c69a895ed47d.png)  
Currently Connected PCs are added to the array OnPostLogin in the game mode.

When setting the Number of Players in the multiplayer settings, that Integer is stored somewhere, that is what I need to get.

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [December 29, 2022, 6:23pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/4 "2022-12-29T18:23:40Z")

</div>

this is not the number of players in multiplayer…  
this number is just the setup how many PIE/Standalone instances to be spawned to test Multiplayer in a fake and latency free environment.

You need to define the Max Player count per session by yourself with an integer variable and update session settings for max players and current players by yourself.

---

<div class="post-metadata">

**Author:** ![Ghullie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ghullie/32/727344_2.png) [@Ghullie](https://forums.unrealengine.com/u/Ghullie)\
**Post date:** [December 29, 2022, 6:34pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/5 "2022-12-29T18:34:55Z")

</div>

> [@BDC\_Patrick](#):
>
> this number is just the setup how many PIE/Standalone instances to be spawned to test Multiplayer in a fake and latency free environment.

Yes and the question is how can I access this number with blueprints?

This is just for testing purposes, sometimes i need to test stuff with 1 player sometimes 2 or more. I want to automate the process where the match starts based on how many PIE instances are being launched. Not how many max players there are supposed to be. (This is already handled in a non testing environment)

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [December 29, 2022, 6:51pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/6 "2022-12-29T18:51:11Z")

</div>

i don’t think there is a way to get editor settings in runtime.  
what you can try is to load the Editor ini file, read it until you get the correct line and take the value as int.

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [December 31, 2022, 10:32am UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/8 "2022-12-31T10:32:15Z")

</div>

> [@Ghullie](#):
>
> Quick question, is there a way to access this Int with blueprints?
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/9/c/89cb15fbc74cd542143910850b83050ed690f46b.png)

This is how the menu gets the number.

```auto
int32 FInternalPlayWorldCommandCallbacks::GetNumberOfClients()
{
	const ULevelEditorPlaySettings* PlayInSettings = GetDefault<ULevelEditorPlaySettings>();
	int32 PlayNumberOfClients(0);
	PlayInSettings->GetPlayNumberOfClients(PlayNumberOfClients);	// Ignore 'state' of option (handled externally)
	return PlayNumberOfClients;
}

```

---

<div class="post-metadata">

**Author:** ![Ghullie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ghullie/32/727344_2.png) [@Ghullie](https://forums.unrealengine.com/u/Ghullie)\
**Post date:** [January 2, 2023, 10:20am UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/9 "2023-01-02T10:20:17Z")

</div>

> [@AntiGravity](#):
>
> **Get Num Players** node???

Unfortunately same issue as above, it only registers players as they login. Not useful in my case

> If that doesn’t work see if you can supply command-line param that can be passed both to the editor, and also parsed as a runtime command-line string?

Do you have any examples of how this would work?

> [@GarnerP57](#):
>
> This is how the menu gets the number.

Is there a way I can run/modify this function to run with blueprints?

---

<div class="post-metadata">

**Author:** ![Ghullie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ghullie/32/727344_2.png) [@Ghullie](https://forums.unrealengine.com/u/Ghullie)\
**Post date:** [February 8, 2023, 12:50am UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/11 "2023-02-08T00:50:46Z")

</div>

@BDC_Patrick has the answer that worked for me.

> [@BDC\_Patrick](#):
>
> i don’t think there is a way to get editor settings in runtime.  
> what you can try is to load the Editor ini file, read it until you get the correct line and take the value as int.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/e/37e60b6ae7431162400b18b1892b4cd912fe17e4.png)

**"(YOURPROJECT)/Saved/Config/WindowsEditor/EditorPerProjectUserSettings.ini**

Is the path to the file containing the info, from there you are looking for “ **PlayNumberOfClients=** ”

It should be noted I use the plugin Easy CSV to get the “Load String from Local File” node, but there are other ways too.

---

<div class="post-metadata">

**Author:** ![Samathan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/samathan/32/1058905_2.png) [@Samathan](https://forums.unrealengine.com/u/Samathan)\
**Post date:** [June 16, 2024, 12:38am UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/12 "2024-06-16T00:38:31Z")

</div>

Note of advice for anyone who wants to do this: to use the `ULevelEditorPlaySettings` class, you need the `UnrealEd` module in your Build.cs dependencies. It’s not super obvious because the class isn’t explicitly declared as a part of the UnrealEd API, but it is.

---

<div class="post-metadata">

**Author:** ![flippyflops.l7d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flippyflops.l7d](https://forums.unrealengine.com/u/flippyflops.l7d)\
**Post date:** [October 19, 2024, 4:42pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/13 "2024-10-19T16:42:12Z")

</div>

> [@Samathan](#):
>
> `UnrealEd`

Is there a way to prevent `UnrealEd ` from being packaged? I want to use this for getting a stable net ID while developing locally with PIE.

```c++
// Required "UnrealEd " build entry, but I don't want to include that module in my shipped game.
FString UVeilFunctionLibrary::GetNetId(const AController* Controller)
{
#if WITH_EDITOR
	if (const UEditorEngine* EditorEngine = Cast<UEditorEngine>(GEngine))
	{
		TOptional<FPlayInEditorSessionInfo> PieInfo = EditorEngine->GetPlayInEditorSessionInfo();
		if (PieInfo.IsSet())
		{
			static int32 PieNetId = 0;
			PieNetId = (PieNetId % PieInfo->NumViewportInstancesCreated) + 1;
			return FString::FromInt(PieNetId);
		}
	}
#endif
	
	const APlayerState* PlayerState = Controller->PlayerState;
	return PlayerState->GetUniqueId().GetUniqueNetId()->ToString();
}

```

---

<div class="post-metadata">

**Author:** ![flippyflops.l7d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flippyflops.l7d](https://forums.unrealengine.com/u/flippyflops.l7d)\
**Post date:** [October 19, 2024, 4:45pm UTC](https://forums.unrealengine.com/t/get-the-number-of-players-from-pie/737925/14 "2024-10-19T16:45:45Z")

</div>

nvm, I found another post describing how to do this:

> [@How to deal with Editor-only Modules in non-Editor build targets?](https://forums.unrealengine.com/t/how-to-deal-with-editor-only-modules-in-non-editor-build-targets/1340279/3):
>
> Okey, found the solution, here: Changing module “Type” did nothing in my case. I merged the two modules back to only one and used the following condition in [plugin].Build.cs : if (Target.bBuildEditor) { PublicDependencyModuleNames.AddRange(new string[]{"UnrealEd",}); } I also had to wrap every header that comes from “UnrealEd” with #if WITH\_EDITOR My project finally compiles to Shipping relieved
