07.06.2012, 02:40
I personally believe you're better off using BlueG's threaded queries. Something along these lines:
The above is threaded and doesn't pause your script while awaiting a response from the database. I am just gonna assume you know how to convert a string to a value. ( strval *cough* ).
You should also have a look at this very important post related to that system:
https://sampforum.blast.hk/showthread.php?tid=337810
and for security issues that come up with this threaded architecture check this one out:
http://forum.sa-mp.com/showpost.php?...postcount=2141
You'll find the link above at the end of the first thread as well and there will be another one explaining how it all works and how you may retrieve the info. I am sure you'll find your way through =).
Regards.
pawn Код:
new str[128]; // cbf to count for an example lol
// Remember to actually escape the name, otherwise u'll be vulnerable for SQL Injections
format(str, 128, "SELECT Username, Fines FROM `Accounts` WHERE `Username` = '%s'", NameEntered);
mysql_function_query( connectionHandle, str, true, "StoreMDC", "i", playerid );
forward StoreMDC(playerid);
public StoreMDC(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
new tmp[2][32];
cache_get_field_content(0/*row*/, "Username", tmp[0], connectionHandle);
cache_get_field_content(0, "Fines", tmp[1], connectionHandle);
}
return 1;
}
You should also have a look at this very important post related to that system:
https://sampforum.blast.hk/showthread.php?tid=337810
and for security issues that come up with this threaded architecture check this one out:
http://forum.sa-mp.com/showpost.php?...postcount=2141
You'll find the link above at the end of the first thread as well and there will be another one explaining how it all works and how you may retrieve the info. I am sure you'll find your way through =).
Regards.