28.03.2015, 12:21
Hello everybody. I have problem with loading a vehicles from database...
First I tried to load vehicles without threeded query, but it showed there are no tables with that name
Then I tried to threed query, but I need to parameters (playerid, vehicleid), but I don't know how to do that...
So code:
Thanks in advice
First I tried to load vehicles without threeded query, but it showed there are no tables with that name
Then I tried to threed query, but I need to parameters (playerid, vehicleid), but I don't know how to do that...
So code:
PHP код:
stock LoadCar(playerid, vehicleid)
{
new query[128];
mysql_format(MySQL, query, sizeof(query), "SELECT * FROM `masinos` WHERE Savininkas='%s' AND uzkrauta='0'", Vardas(playerid));
mysql_tquery(MySQL, query, "loadcar", "i", playerid,vehicleid);
}
PHP код:
forward loadcar(playerid,vehicleid);
public loadcar(playerid,vehicleid)
{
new query[128];
new spalva[2];
vehicleDB[vehicleid][gas] = cache_get_field_content_int(0, "Degalai");
vehicleDB[vehicleid][lastuser] = cache_get_field_content_int(0, "pVaziavo");
vehicleDB[vehicleid][Masinos_Modelis] = cache_get_field_content_int(0, "Modelis");
vehicleDB[vehicleid][lastpos][0] = cache_get_field_content_float(0, "X");
vehicleDB[vehicleid][lastpos][1] = cache_get_field_content_float(0, "Y");
vehicleDB[vehicleid][lastpos][2] = cache_get_field_content_float(0, "Z");
vehicleDB[vehicleid][lastpos][3] = cache_get_field_content_float(0, "A");
spalva[0] = cache_get_field_content_int(0, "Spalva1");
spalva[1] = cache_get_field_content_int(0, "Spalva2");
vehicleDB[vehicleid][owner_name] = Vardas(playerid);
masina[playerid][vehicleid] = CreateVehicle(vehicleDB[vehicleid][Masinos_Modelis], vehicleDB[vehicleid][lastpos][0], vehicleDB[vehicleid][lastpos][1], vehicleDB[vehicleid][lastpos][2], vehicleDB[vehicleid][lastpos][3], spalva[0], spalva[1], -1);
mysql_format(MySQL, query, sizeof(query), "UPDATE `masinos` SET uzkrauta='1' WHERE Savininkas='%s' AND Modelis='%d'",Vardas(playerid), vehicleDB[vehicleid][Masinos_Modelis]);
mysql_tquery(MySQL, query);
}