Best Way To Hook Up Website SQL Database

Hey all! I have a bit of an interesting question.

I am making a Creature Capture MMO and i have just paid for an external Website to host my Database for the players information.

Im using One.Com thats uses Myphpadmin for the Database storage. Im trying to figure out how to connect my Database up to Unreal so i can save/load the data into my game when a player logs on/off.

I cant seem to find much documentation or tutorials that will show me the best practise to do this. If anyone knows an easy method to connect up the database to Unreal id appreciate it

Hmm looks like you need to develop your own form of authentication system with some php http endpoints for your game to post and get data.

1 Like

Interesting any ideas where to start with that? If you know of any videos or documentation i can read through that would be epic :grin:

Well it looks like you’ll have access to php if you got their hosting plan so they might have a webpage editor for your servers files so you can live edit the php, otherwise you might have to upload files using ftp or ssh.

After you figure out where php is running the active directory of your domain on your server and how to edit the files then you can register an endpoint, something like this:

You’ll want to split up your endpoints for optimization but youll probably need a few like sign-up and login and get-user-data and save-user-data. There are things here you should do to protect your endpoints as well from brute-force attacks and non-signed clients otherwise any one or bot could access them as much as they want such as ip limiting and authorized headers. Your sign-up function should post variables to your database from the php endpoint that would be http called in ue. The login should give the user an access token that will be used on each call and could even be refreshed every call too for more security. though you could use something like the steam api to use user id’s but then you wont get cross platform play. Etc etc… the game data functions would take the auth token and use it to load and save variables from the http into the sql database.

In UE you could use one of the many http plugins and or the builtin c++ http module to handle the data.

This is definitely quite an abridged breakdown, but if you have any more questions feel free to ask!

1 Like

Thanks a bunch this gives me an avenue to explore! I’ll take a look at this tomorrow :smiley: Thanks a lot!

The most important part of this: Do not put any kind of password or credential for the website or database into your game client. Users will disassemble the client, find it out, and hack your database.
Instead, write web services in your web host (can be simple PHP that accepts JSON and returns JSON in a POST handler)

The second most important part of this: Don’t just accept unauthenticated requests in the web service. Require that users create an account of some sort (either email/password on your site, or “sign in with google,” or tie into a Steam or other online provider subsystem.)
Else you have no recourse in knowing who to ban when someone abuses the system.

The third most important thing: Post game control information, rather than game outcome information, and let the server make the decisions.
Else, users will just figure out how to post “give me the +10 Flaming Sword of Fire object” or “I caught all the monsters and got 1,000,000,000,000 points.”
So, for example, post “player entered zone 4” and maybe in response the server says “the player sees monster 3.” Then post “player uses one monsterball when trying to capture monster 3” and the server rolls the dice and tells the game the outcome. If the player tries to capture a monster when they have no balls, or the player tries to capture a monster they haven’t seen, or somesuch, return an error.

The role of the client is to let the user express interactions and see the results in a delightful way; the high-level interactions are then resolved by the game server.

In Ureal Engine, you have the built-in HTTP support, but you can also find plugins in the marketplace for talking HTTP and JSON.

1 Like

Thats really useful things to consider thank you! I’ve just been looking at VaRest would this be a useful plugin i can use to get the result i need?