I am attempting to create a simple C++ 'script' which will allow me to read in information from a database (not yet created). I have the script working by reading in values from a *.config file, but I really do need it to be a database.
This will be used for an MMO video game. The following is some sample code:
player->TeleportTo(1, 9947.52f, 2482.73f, 1316.21f, 0.0f);
player->ModifyMoney(-(Config.GetFloatDefault("TeleCost",0)));
As you can see in the second line, I am reading in the 'TeleCost' in order to modify the player's money.
What I really would like to do, is change the first line so it is reading in every single one of the variables from a DB:
1 = MapID
9947.52f = X position
2482.73f = Y position
1316.21f = Z position
0.0f = Rotation
I'd also like to change the 'TeleCost' so it is included in the same line in the DB so I can give each teleport location it's own cost:
Config.GetFloatDefault("TeleCost",0) = TeleCost
I'd like to name the DB "TeleNet".
So....
1. What code is needed in order to make this script find the DB? I assume it will need the connection info such as port number, database name, password, etc? How do I set that part up?
2. Once I get the script so it can read the database in question #1, how would I change my hard-coded variables to some code that can read values from the DB?
EDIT:
Let me make this a little bit easier... (Hopefully).
I already have a Database that I can use, I just need to add a new table to it. I am about 90% certain I can already connect to this database, but I will need my own table. The table will be called TeleNet.
Edited 1 time(s). Last edit at 09/25/2009 10:14PM by Nicolai Dutka.