14.08.2011, 02:21
Is it possible to load data from SQLite via sscanf? If so, could someone provide an example...?
#define MAX_RET_STR 500
stock db_get_row(query[])
{
new DBResult:Result, retstr[MAX_RET_STR], FieldName[50], singleresult[100];
Result = db_query(query);
new numfields = db_num_fields(Result);
for(new a;a<numfields;a++)
{
db_field_name(Result, a, FieldName, 50);
db_get_field_assoc(Result, FieldName, singleresult, 100);
format(retstr, sizeof(retstr), "%s|%s", retstr, singleresult);
}
return retstr[1];
}
User|Pass|Kills|Deaths|etc..
//Will return
[HiC]TheKiller|MyPass|20|30|etc..
new Line[750];
format(Line, 750, "%s", db_get_row("SELECT * FROM userdata WHERE username = '[HiC]TheKiller'"));
sscanf(Line, "....", .....);