Need Help
#1

Ok, ive never worked with sscanf so i tried to make a loadvehicles stock using the only way i could think of. I tried this but i did not work at all, can someone convert it to sscanf?

pawn Код:
stock LoadVehicles()
{
    new Query[255];
    for(new id; id < MA; id++)
    {
        format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE id= %d", id);
        mysql_query(Query);
        mysql_store_result();
        if(mysql_num_rows())
        mysql_fetch_field("Model", vehicledata[id][Model]);
        mysql_fetch_field("x", vehicledata[id][POS][0]);
        mysql_fetch_field("y", vehicledata[id][POS][1]);
        mysql_fetch_field("z", vehicledata[id][POS][2]);
        mysql_fetch_field("a", vehicledata[id][POS][3]);
        mysql_fetch_field("Owner", vehicledata[id][Owner]);
        mysql_fetch_field("Forsale", vehicledata[id][Forsale]);
        mysql_fetch_field("Price", vehicledata[id][Price]);
        new Color1 = random(126); new Color2 = random(126);
        CreateVehicle(vehicledata[id][Model],vehicledata[id][POS][0],vehicledata[id][POS][1],vehicledata[id][POS][2],vehicledata[id][POS][3],Color1,Color2, 60*10000);
    }
}
Reply
#2

Plz help i really dont know how.
Reply
#3

Quote:
Originally Posted by Rokzlive
Посмотреть сообщение
Plz help i really dont know how.
I believe the query should be formated like this :

pawn Код:
format(Query, sizeof(Query), "SELECT field1, field2 etc here FROM vehicles WHERE id= %d", id);
Reply
#4

But then how do i set what it gets to the variable. For example how do i assign what name it pulls from owner and set it to vehicledata[vehicleid][Owner]?
Reply
#5

pawn Код:
mysql_fetch_row(Query, "|");
sscanf(Query, "p<|> i(int) s[string length](string) f(float)", vars here);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)