Is there an equivalent of #if WITH_SERVER_CODE in Blueprints?

Hi!

Is there an equivalent of this in BP (or about to come out?)


 void MyServerOnlyFunction()
 {
 #if WITH_SERVER_CODE
     Do Server Stuff here;
 #endif
 }
 

The logic in the WITH_SERVER_CODE will NOT EXIST in the client binary. that makes building dedicated servers pretty smooth.

regards

I don’t think so. That’s pretty “advanced” for Blueprints.

If you want to have things like these you will need to stick to C++.

Could also be wrong, but in 2+ years of UE4, I did not encounter that in BPs :stuck_out_tongue:

1 Like

For Blueprints you pretty much have to create classes that are never used in client; compiler directives there won’t work.
However the code will still be visible in the client source code… So in general is just better to simply build the server in C++ if security for you is a concern (ppl really will scan your game’s classes you know, I’ve seen plenty of exposed code, from ARK for example, around internet that was extracted from the game client).

Its really confusing a bit…

Lets say I create a “player controller class” in blueprints - and a “player controller server helper class” in c++. I can now wrap the whole server class into the server directive.
So code from the server class wont exist in the client binaries.

Can i still use the helper as variable in the player controller? What happens if i only use the directive inside a function (before return, and at the start…) and i expose it per attribute to blueprints… I probably can cast to the class in the bp and use the function but nothing will happen on client side… so i guess if i want to move the player in the function I destroyed the actual replication system a bit (since the player wont even move until the server really says hey dude u are actually here…)

Whats the best practise in regards to working with bp but still making a decently secure multiplayer but not destroy ue4 base functionality like replication…?