Banks in mysql [+REP] -
E7mad - 21.12.2015
Hello everyone, I've thought about making a bank for the server in mysql.
So, all what will be saved is, Balance (the amount of money), and the bank manager.
Of course, I have to make a new table, but how? like users table or what?
Re: Banks in mysql [+REP] -
VVWVV - 21.12.2015
Use the table with user accounts. Create columns with names: money, card(if necessary), etc.
Re: Banks in mysql [+REP] -
SecretBoss - 21.12.2015
Well, balance and manager are not enough you will need something like name so you can make a query to get player's money or if player is manager, in case you want to create a table go to your phpmyadmin site, which one is provided from your host and click on your database then in bottom you will find a box named Create Table, create a table and put your columns there
Re: Banks in mysql [+REP] -
IzadorO - 21.12.2015
Код:
Query the following: CREATE TABLE IF NOT EXISTS `bank` (`Balance` INTEGER DEFAULT 0 NOT NULL, `Manager` VARCHAR(24), `ID` INTEGER NOT NULL PRIMARY KEY)
Create a bank enumerator for storing all of the SQL bank data in to their correct variables (and setting the bank enumerator values to their correct SQL variable).
Enumerator Example:
Код:
enum BankData
{
bID,
bBalance,
bManager[24],
};
new bData[MAX_BANK][BankData];
Updating the SQL table (example):
Код:
"UPDATE `bank` SET `Balance` = %d, `Manager` = '%s' WHERE `ID` = %d", bData[bankid][bBalance], bData[bankid][bManager], bData[bankid][bID]
Loading the bank table's data from the SQL server and storing it in to the BankData enumerator:
Код:
"SELECT * FROM `bank` WHERE `ID` = %d", bData[bankid]);
new rows, fields;
cache_get_data(rows, fields, serverhandle);
for (new i = 0; i < rows; i ++)
{
bData[bankid][bID] = cache_get_field_int(i, "ID")
bData[bankid][bBalance] = cache_get_field_int(i, "Balance")
cache_get_field_content(i, "Manager", bData[bankid][bManager], serverhandle, 24);
}
You can figure the rest out through SQL tutorials. You also have to create your own callbacks and sort the above scripting in to the correct callbacks.
Re: Banks in mysql [+REP] -
E7mad - 22.12.2015
Quote:
Originally Posted by IzadorO
Код:
Query the following: CREATE TABLE IF NOT EXISTS `bank` (`Balance` INTEGER DEFAULT 0 NOT NULL, `Manager` VARCHAR(24), `ID` INTEGER NOT NULL PRIMARY KEY)
Create a bank enumerator for storing all of the SQL bank data in to their correct variables (and setting the bank enumerator values to their correct SQL variable).
Enumerator Example:
Код:
enum BankData
{
bID,
bBalance,
bManager[24],
};
new bData[MAX_BANK][BankData];
Updating the SQL table (example):
Код:
"UPDATE `bank` SET `Balance` = %d, `Manager` = '%s' WHERE `ID` = %d", bData[bankid][bBalance], bData[bankid][bManager], bData[bankid][bID]
Loading the bank table's data from the SQL server and storing it in to the BankData enumerator:
Код:
"SELECT * FROM `bank` WHERE `ID` = %d", bData[bankid]);
new rows, fields;
cache_get_data(rows, fields, serverhandle);
for (new i = 0; i < rows; i ++)
{
bData[bankid][bID] = cache_get_field_int(i, "ID")
bData[bankid][bBalance] = cache_get_field_int(i, "Balance")
cache_get_field_content(i, "Manager", bData[bankid][bManager], serverhandle, 24);
}
You can figure the rest out through SQL tutorials. You also have to create your own callbacks and sort the above scripting in to the correct callbacks.
|
Thank you very much!
That's a complete answer.
+1337REP
Re: Banks in mysql [+REP] -
E7mad - 22.12.2015
Sorry for double-post.
But, where to put that code "CREATE TABLE IF NOT .."?
And the ID of bank auto increases?
And when I compile it, it says: "error 017: undefined symbol "bankid"
How to define the "bankid" ?
Re: Banks in mysql [+REP] -
E7mad - 22.12.2015
Sorry for Bump
But my question is: How to define the "bankid"? When I do "bData[bankid][bBalance]" it says: "Undefined symbol "bankid", I mean how can I be able to do bData[
bankid][bBalance] ?
ANSWER ASAP PLEASE!