21.02.2015, 09:36
Код:
public LoadPersonalVehicles() { new arrCoords[41][64],sql[512],row[512]; format(sql, sizeof(sql), "SELECT COUNT(id) FROM cars"); mysql_query(sql); SQLLog(sql); mysql_store_result(); mysql_fetch_row(row); totalcars = strval(row); new bc = AddStaticVehicleEx(411, 0, 0, 0, 0, 0, 0, -1); //Pentru a determina urmatorul ID DestroyVehicle(bc); if(totalcars>0) { for (new idx=1; idx<=totalcars; idx++) { format(sql, sizeof(sql), "SELECT * FROM carss WHERE id=%d", idx); mysql_query(sql); SQLLog(sql); mysql_store_result(); if (mysql_num_rows() > 0) { mysql_fetch_row(row); split(row, arrCoords, '|'); VehicleInfo[bc][cId] = strval(arrCoords[0]); VehicleInfo[bc][cModel] = strval(arrCoords[1]); VehicleInfo[bc][cLocationx] = floatstr(arrCoords[2]); VehicleInfo[bc][cLocationy] = floatstr(arrCoords[3]); VehicleInfo[bc][cLocationz] = floatstr(arrCoords[4]); VehicleInfo[bc][cAngle] = floatstr(arrCoords[5]); VehicleInfo[bc][cSaLocationx] = floatstr(arrCoords[6]); VehicleInfo[bc][cSaLocationy] = floatstr(arrCoords[7]); VehicleInfo[bc][cSaLocationz] = floatstr(arrCoords[8]); VehicleInfo[bc][cSaAngle] = floatstr(arrCoords[9]); VehicleInfo[bc][cColorOne] = strval(arrCoords[10]); VehicleInfo[bc][cColorTwo] = strval(arrCoords[11]); VehicleInfo[bc][cOwner] = strval(arrCoords[12]); VehicleInfo[bc][cDescription] = strval(arrCoords[11]); VehicleInfo[bc][cValue] = strval(arrCoords[12]); VehicleInfo[bc][cLicense] = strval(arrCoords[13]); VehicleInfo[bc][cOwned] = strval(arrCoords[14]); VehicleInfo[bc][cLockk] = strval(arrCoords[15]); VehicleInfo[bc][cNum] = strval(arrCoords[16]); VehicleInfo[bc][cComponent01] = strval(arrCoords[17]); VehicleInfo[bc][cComponent02] = strval(arrCoords[18]); VehicleInfo[bc][cComponent03] = strval(arrCoords[19]); VehicleInfo[bc][cComponent04] = strval(arrCoords[20]); VehicleInfo[bc][cComponent05] = strval(arrCoords[21]); VehicleInfo[bc][cComponent06] = strval(arrCoords[22]); VehicleInfo[bc][cComponent07] = strval(arrCoords[23]); VehicleInfo[bc][cComponent08] = strval(arrCoords[24]); VehicleInfo[bc][cComponent09] = strval(arrCoords[25]); VehicleInfo[bc][cComponent10] = strval(arrCoords[26]); VehicleInfo[bc][cComponent11] = strval(arrCoords[27]); VehicleInfo[bc][cComponent12] = strval(arrCoords[28]); VehicleInfo[bc][cComponent13] = strval(arrCoords[29]); VehicleInfo[bc][cKM] = strval(arrCoords[30]); VehicleInfo[bc][cPaintJob] = strval(arrCoords[31]); new car = AddStaticVehicleEx(VehicleInfo[bc][cModel], VehicleInfo[bc][cLocationx], VehicleInfo[bc][cLocationy], VehicleInfo[bc][cLocationz], VehicleInfo[bc][cAngle], VehicleInfo[bc][cColorOne], VehicleInfo[bc][cColorTwo], -1); SetVehicleToRespawn(car); if(IsATruck(car)) { PlayerHaul[car][pCapasity] = 200; } bc++; } } } mysql_free_result(); printf("%d Vehicles Loaded", totalcars); return 0; }