I have made a mysql connection with a plugin and connected it on a run on server event and checking for authority of course with blueprint so im going to use dedicated servers i was wondering if client can access the db credentials from their source
If you have embedded the credentials in the source code, then yes, a technically competent user could extract them from the binary.
Load them from a file, ensure that file is only packaged for dedicated server builds (see reply in this topic).
So im using blueprints i dont really understand the part how do we seperate dedicated build and client build and what happens if i seperate them the bp events marked as run on server goes to dedicated build run on owning client goes to client build?
This will be difficult to achieve in BP only, and I am 99% sure you actually need to compile the engine yourself to build a dedicated server anyway.
How do get the credentials in now? They are params on a BP node from the plugin?
Yup they are params in a plugins bp node
Tricky, nothing ‘server only’ is going to be excluded from a normal build (listen servers are a thing), so the creds would be included.
Will be easy enough to do in C++, which you are actually going to have to deal with to some degree anyway to build the dedicated server.
I’d recommend start looking into the process of a getting a dedicated server built, once you have C++ project files and everything builds you can add a function to load them from an external file; and do not include that file anywhere in you content, just drop it in place for the server.
First of all thanks for your answer and sorry for the late response i had a funeral, anyways what would i need to do if i wanted to completely seperate client and server code from each other? Is it possible?
You can use preprocessor definitions to conditionally compile.
Not something I have done with Unreal myself as yet, but the following method should work I believe,
In the YourProject.build.cs file (constructor) add a define if building server:
if (Target.Type == TargetType.Server)
PublicDefinitions.Add("_IS_DEDICATED_SERVER_");
then you can test for the define in your code where needed, to only include certain code for a server, provide alternative implementations depending on target, or just fill in variables differently based on the target.
Example of the latter:
# ifdef _IS_DEDICATED_SERVER_
DatabaseConnectionString = "Server=...;Database=...;Uid=...;Pwd=...;";
# else
DatabaseConnectionString = "";
# endif