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
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!
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.