14.01.2012, 16:56
OK, first, you need these defines, to make it all easier:
OK, then:
That's it, just replace the field names and correct mistakes such as me putting "fetch_int" when there's a string, etc.
pawn Код:
#define fetch_int(%1,%0) mysql_fetch_field_row(%0,field); \
%1=strval(field)
#define fetch_float(%1,%0) mysql_fetch_field_row(%0,field); \
%1=floatstr(field)
#define fetch_string(%1,%0) mysql_fetch_field_row(%0,%1)
pawn Код:
for(new v=0; v<sizeof(vInfo); v++) {
format(mysql, sizeof(mysql), "SELECT * FROM `vehicles` WHERE `VID`=%d", v);
mysql_query(mysql);
mysql_store_result();
new field[256]; // big, has to be AFAIK
if(mysql_retrieve_row()) {
fetch_int("FIELDNAME", vInfo[v][vID]);
fetch_int("FIELDNAME", vInfo[v][vModel]);
fetch_string("FIELDNAME", vInfo[v][vOwner]);
fetch_int("FIELDNAME", vInfo[v][vLocked]);
fetch_int("FIELDNAME", vInfo[v][vLock]);
fetch_int("FIELDNAME", vInfo[v][vAlarm]);
fetch_int("FIELDNAME", vInfo[v][vInsurance]);
fetch_int("FIELDNAME", vInfo[v][vColor1]);
fetch_int("FIELDNAME", vInfo[v][vColor2]);
fetch_string("FIELDNAME", vInfo[v][vPlate]);
fetch_float("FIELDNAME", vInfo[v][vX]);
fetch_float("FIELDNAME", vInfo[v][vY]);
fetch_float("FIELDNAME", vInfo[v][vZ]);
fetch_int("FIELDNAME", vInfo[v][vOwned]);
}
CreateVehicle(vInfo[v][vModel], vInfo[v][vX], vInfo[v][vY], vInfo[v][vZ], 1.0, vInfo[v][vColor1], vInfo[v][vColor2], 1000);
mysql_free_result();
}