21.04.2011, 19:43
I write this code and it was working very well but i depared with something was lefting so i added it but this is making the load thing stop and not loading at all... I added the vid and made it loop trought all cars and it is stoping the load thing i dont know why if I remove the vid thing it will load. Any help? I know is a lot of code but is clean and easy to understand.Thank you!
pawn Код:
stock LoadGlobalVehicles()
{
new query[1021];
new count = 0;
for(new i; i < MAX_VEHICLES; i++)
{
format(query, sizeof(query),"SELECT * FROM vehicles WHERE carid= %d && Type != 1",i);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows())
{
}
else
{ printf("fail"); return 1;}
if(mysql_fetch_row(query, "|"))
{
new field[17][64];
explode(query, field, "|");
mysql_free_result();
count++;
vehicleinfo[i][id] = strval(field[0]);
vehicleinfo[i][Model] = strval(field[1]);
vehicleinfo[i][Color1] = strval(field[2]);
vehicleinfo[i][Color2] = strval(field[3]);
vehicleinfo[i][x] = strval(field[4]);
vehicleinfo[i][y] = strval(field[5]);
vehicleinfo[i][z] = strval(field[6]);
vehicleinfo[i][a] = strval(field[7]);
strcpy(vehicleinfo[i][Owner], field[8], 24);
strcpy(vehicleinfo[i][Name], field[9], 24);
vehicleinfo[i][Lock] = strval(field[10]);
vehicleinfo[i][Insurances] = strval(field[11]);
vehicleinfo[i][Destroyed] = strval(field[12]);
vehicleinfo[i][IPrice] = strval(field[13]);
vehicleinfo[i][Radio] = strval(field[14]);
vehicleinfo[i][Type] = strval(field[15]);
vehicleinfo[i][Engine] = strval(field[16]);
new vid[MAX_VEHICLES];
vid[i] = CreateVehicle(vehicleinfo[i][Model],vehicleinfo[i][x],vehicleinfo[i][y],vehicleinfo[i][z],
vehicleinfo[i][a],vehicleinfo[i][Color1],vehicleinfo[i][Color2],100*1500);
vehiclekey[vid[i]] = i;
}
}
printf("Loaded %d vehicles.",count);
return 1;
}