I want to run a database on my server and I don’t want players to be able to access it, which is why I only program the database login data into the server, but are the server scripts also build in the client version?
Unless you do a fair bit of surgery, all the referenced bits of content will be exported when you build your game. Presumably, you have actors that talk to GameState and so on, so the code will be present, even if the objects aren’t instantiated on the client.
There are two things that worry me about your question, though:
-
You should never hard-code connection credentials into code. Not only is this bad if the code leaks, but it also makes it impossible to run separate test copies of the program that don’t talk to the live database. Instead, use a special ini file that defines a variable for the connection string (or host/name/password/databasename if they need to be different.)
-
You should never operate a database such that it is publicly available to the internet. Even if your users had the connection string, your firewall should prevent anyone from actually talking to the database. This means that your server needs to be on a shared private network with the database, with a reverse-NAT gateway in front, or you need to set your server up with two networks, internal and external. This can be done with a single network card, as long as the rest of your networking infrastructure is up for it.
If we refer to this Targets | Unreal Engine Documentation
Client Target Type should not include any server code. What they mean by server code ? I’m not sure. A way that I think it could work “safely” is : Load a JSON file for your database connection info. With my project I just have a copy of a JSON file that i add to my builded dedicated server and the server load it up. I am relatively new to this too so don’t trust this at 100% ;p jwatte seems to have a better work around