28.02.2015, 01:01
Код:
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); new asd = AddStaticVehicleEx(411, 0, 0, 0, 0, 0, 0, -1); //For the next idID DestroyVehicle(asd); new masinipers = AmountOfVehicles()+2; if(masinipers>0) { for (new idx=1; idx<=masinipers; idx++) { format(sql, sizeof(sql), "SELECT * FROM cars WHERE id=%d", idx); mysql_query(sql); SQLLog(sql); mysql_store_result(); if (mysql_num_rows() > 0) { mysql_fetch_row(row); split(row, arrCoords, '|'); CarData[asd][cId] = strval(arrCoords[0]); CarData[asd][cModel] = strval(arrCoords[1]); CarData[asd][cLocationx] = floatstr(arrCoords[2]); CarData[asd][cLocationy] = floatstr(arrCoords[3]); CarData[asd][cLocationz] = floatstr(arrCoords[4]); CarData[asd][cAngle] = floatstr(arrCoords[5]); CarData[asd][cSaLocationx] = strval(arrCoords[6]); CarData[asd][cSaLocationy] = strval(arrCoords[7]); CarData[asd][cSaLocationz] = strval(arrCoords[8]); CarData[asd][cSaAngle] = strval(arrCoords[9]); CarData[asd][cColorOne] = strval(arrCoords[10]); CarData[asd][cColorTwo] = strval(arrCoords[11]); CarData[asd][cOwner] = strval(arrCoords[12]); CarData[asd][cDescription] = strval(arrCoords[13]); CarData[asd][cValue] = strval(arrCoords[14]); CarData[asd][cLicense] = strval(arrCoords[15]); CarData[asd][cOwned] = strval(arrCoords[16]); CarData[asd][cLockk] = strval(arrCoords[17]); CarData[asd][cNum] = strval(arrCoords[18]); CarData[asd][cComponent00] = strval(arrCoords[19]); CarData[asd][cComponent01] = strval(arrCoords[20]); CarData[asd][cComponent02] = strval(arrCoords[21]); CarData[asd][cComponent03] = strval(arrCoords[22]); CarData[asd][cComponent04] = strval(arrCoords[23]); CarData[asd][cComponent05] = strval(arrCoords[24]); CarData[asd][cComponent06] = strval(arrCoords[25]); CarData[asd][cComponent07] = strval(arrCoords[26]); CarData[asd][cComponent08] = strval(arrCoords[27]); CarData[asd][cComponent09] = strval(arrCoords[28]); CarData[asd][cComponent10] = strval(arrCoords[29]); CarData[asd][cComponent11] = strval(arrCoords[30]); CarData[asd][cComponent12] = strval(arrCoords[31]); CarData[asd][cComponent13] = strval(arrCoords[32]); CarData[asd][cKM] = strval(arrCoords[33]); CarData[asd][cPaintJob] = strval(arrCoords[34]); new car = AddStaticVehicleEx(CarData[asd][cModel], CarData[asd][cLocationx], CarData[asd][cLocationy], CarData[asd][cLocationz], CarData[asd][cAngle], CarData[asd][cColorOne], CarData[asd][cColorTwo], -1); SetVehicleToRespawn(car); asd++; totalcars++; //printf("%d - %d - %d", bc, car, VehicleInfo[bc][vModel]); } } //printf("%d dupa for", totalhouses); } mysql_free_result(); printf("%d Vehicles Loaded", totalcars); return 0; }
Код:
/*public LoadCar() { new Query[255]; mysql_query("SELECT * FROM cars"); // Querys the "Query" Variable. mysql_store_result(); // Stores the result from Query personalcars = mysql_num_rows(); new masini=0; for(new idx = 1; idx <= personalcars; idx++) { format(Query, sizeof(Query), "SELECT * FROM cars WHERE id = '%d'", idx); mysql_query(Query); // Querys the "Query" Variable. mysql_store_result(); // Stores the result from Query if(mysql_num_rows()) // Checks if theres anyrow. if(mysql_fetch_row_format(Query,"|")) // Splits the row { sscanf(Query, "p<|>e<iiffffffffiis[64]s[64]iiiiis[255]iiiiiiiiiiiiiii>",CarData[idx]); masini++; } //printf("id %d car model %d, cLocationx %f, cNum %s, cSaAngle %f, cComponent13 %d",idx, CarData[idx][cModel],CarData[idx][cLocationx],CarData[idx][cNum],CarData[idx][cSaAngle], CarData[idx][cComponent01]); } printf("-Masini citite: %d", masini); return 1; }*/