21.05.2012, 12:54
I have this code that's supposed to load all the cars from database when the gamemode starts. But there's a problem, every car owner is the same person.
This is the owner line..
And there are some others too.. am I using it wrong?
pawn Код:
stock LaeAutod()
{
new query[512];
format(query, sizeof(query), "SELECT * FROM eraautod");
mysql_query(query);
mysql_store_result();
new i = 0;
while(mysql_retrieve_row())
{
new field[64];
mysql_fetch_field_row(field, "model");
AutoInfo[i][aModel] = strval(field);
mysql_fetch_field_row(field, "varv1");
AutoInfo[i][aVarv1] = strval(field);
mysql_fetch_field_row(field, "varv2");
AutoInfo[i][aVarv2] = strval(field);
mysql_fetch_field_row(field, "x");
AutoInfo[i][aX] = floatstr(field);
mysql_fetch_field_row(field, "y");
AutoInfo[i][aY] = floatstr(field);
mysql_fetch_field_row(field, "z");
AutoInfo[i][aZ] = floatstr(field);
mysql_fetch_field_row(field, "a");
AutoInfo[i][aA] = floatstr(field);
new masin = CreateVehicle(AutoInfo[i][aModel], AutoInfo[i][aX], AutoInfo[i][aY], AutoInfo[i][aZ]+1.0, AutoInfo[i][aA], AutoInfo[i][aVarv1], AutoInfo[i][aVarv2], -1);
mysql_fetch_field_row(field, "id");
AutoInfo[masin][aID] = strval(field);
mysql_fetch_field_row(field, "omanik");
AutoInfo[masin][aOmanik] = strmid(AutoInfo[masin][aOmanik], field, 0, 24, 255);
mysql_fetch_field_row(field, "numbrimark");
AutoInfo[masin][aNumbrimark] = strmid(AutoInfo[masin][aNumbrimark], field, 0, strlen(field), 255);
SetVehicleNumberPlate(masin, AutoInfo[masin][aNumbrimark]);
SetVehicleVirtualWorld(masin, 0);
i++;
}
mysql_free_result();
print("[MYSQL] Autod serverisse laetud!");
return 1;
}
pawn Код:
AutoInfo[masin][aOmanik] = strmid(AutoInfo[masin][aOmanik], field, 0, 24, 255);