Converting MYSQL Saving Codes into .INI Saving System codes ????
#7

Quote:
Originally Posted by PURG3D
View Post
Because MYSQL is hardcore coding for me. And i think theres no else solution that can solve my problem in my previous thread.
It's easier than dini. Just look at examples of loading/saving functions such as a registration system. Just a waste of time and effort converting back to a disadvantaged method.

Basically when the gamemode connects you want to connect to the mySQL using the function: mysql_connect().

On register you want to create a new row, all the values you really should need to put in are the important values: name, password ect. You will want to use mysql_format() for this to INSERT. Reminder! For all user input strings you want to use '%e' instead of '%s', this will escape the string. If you don't you are vulnerable to injections. After that: mysql_tquery. Same applies to saving data!!

On login you want to SELECT from mySQL. You want to loop through each row in mySQL using cache_get_row_count(),
for(new i = 0; i < cache_get_row_count(); i++)
{
... load row inside here.

}

When loading data it's important that you fetch the player name from that row, match it, then check that the input password is the same! NOTE: encrypt the password the user inputs, and check it with an already encrypted password saved to mySQL.

When saving, you want to update a mySQL row. Below is an example,

mysql_format(connection_handle, string, sizeof(string), "UPDATE `tablename` SET `Money` = %d`WHERE `name`='%e'", player_money, player_name);
mysql_tquery(mysql_tquery(connection_handle, string, "", "");

connection_handle is the variable that stores the mysql connection: connection_handle = mysql_connect(...)


Do some research buddy. I have provided an example in a different context, the concept remains the same!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)