MYSQL Code Mistake

Started by KrOoB_, Dec 06, 2018, 07:57 PM

Previous topic - Next topic

KrOoB_

where's mistake

function LoadVehicles()
{
local start = clock();
local q4 = mysql_query(db, "SELECT Model, Position, Angle, Col1, Col2, Parked, rowid FROM vehicles"), splitPos, x, y, z, splitPark, px, py, pz, ax, ay, az
local q5;
local i = 0;
while (q5 = mysql_fetch_row(q4))
{
mysql_query( db, "UPDATE vehicles SET rowid = "+i+" WHERE Position="+q5[5]+"");
local model = q5[0];
splitPos = split(q5[1], ", ");
x = splitPos[0];
y = splitPos[1];
z = splitPos[2];
local Angle = q5[2];
local Col1 = q5[3];
local Col2 = q5[4];
CreateVehicle(model.tointeger(), 0, Vector(x.tofloat(), y.tofloat(), z.tofloat()), Angle.tofloat(), Col1.tointeger(), Col2.tointeger());
if (q5[5] != "N")
{
splitPark = split(q5[5], ", ");
px = splitPark[0];
py = splitPark[1];
pz = splitPark[2];
ax = splitPark[3];
ay = splitPark[4];
az = splitPark[5];
FindVehicle(i).SpawnPos = Vector(px.tofloat(), py.tofloat(), pz.tofloat());
FindVehicle(i).Pos = Vector(px.tofloat(), py.tofloat(), pz.tofloat());
FindVehicle(i).EulerSpawnAngle = Vector(ax.tofloat(), ay.tofloat(), az.tofloat());
FindVehicle(i).EulerAngle = FindVehicle(i).EulerSpawnAngle;
}
i++;
if (i == mysql_num_rows(q4))
{
local finish = clock() - start;
print(i + " vehicles created in " + finish + " sec");
}
}
mysql_free_result(q4);
GetSQLNextRow(q4);
}

MatheuS

local q4 = mysql_query(db, "SELECT Model, Position, Angle, Col1, Col2, Parked, rowid FROM vehicles"), splitPos, x, y, z, splitPark, px, py, pz, ax, ay, az
this line is not complete
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

KrOoB_