Problem in my vehicle system.
#9

OK, first, you need these defines, to make it all easier:
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)
OK, then:
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();
}
That's it, just replace the field names and correct mistakes such as me putting "fetch_int" when there's a string, etc.
Reply


Messages In This Thread
Problem in my vehicle system. - by printer - 14.01.2012, 13:27
Re: Problem in my vehicle system. - by Mean - 14.01.2012, 13:30
Re: Problem in my vehicle system. - by printer - 14.01.2012, 13:38
Re: Problem in my vehicle system. - by Mean - 14.01.2012, 14:06
Re: Problem in my vehicle system. - by printer - 14.01.2012, 15:58
Re: Problem in my vehicle system. - by Mean - 14.01.2012, 16:00
Re: Problem in my vehicle system. - by Mean - 14.01.2012, 16:03
Re: Problem in my vehicle system. - by printer - 14.01.2012, 16:32
Re: Problem in my vehicle system. - by Mean - 14.01.2012, 16:56
Re: Problem in my vehicle system. - by printer - 14.01.2012, 17:31

Forum Jump:


Users browsing this thread: 2 Guest(s)