04.11.2010, 19:05
(
Последний раз редактировалось Gabb0411; 06.11.2010 в 08:47.
)
Hello guys , i want to make a MYSQL Car System and i want to add cars from MySQL without modify any thing in the code.
I have 2 tables : Servervehicles and Personalcars.
The Servervehicles are spawning first and personalcars are spawning second.
The problem is with Personalcars.
In PersonalCars table from MySQL , i've put the ID's from 500. ( this is the reason why i put for(new idx = 500...)
I open the server and my gamemode is spawning 500 vehicles at same coordinates ( He is spawning 500 times the first car from PersonalCars table. ).
How can i fix this? I want to add cars in my server without modify any code in .pwn.
I have 2 tables : Servervehicles and Personalcars.
The Servervehicles are spawning first and personalcars are spawning second.
The problem is with Personalcars.
Код:
public LoadSQLCars() { new car[37][64]; new sql[80]; new row[1024]; format(sql, sizeof(sql), "SELECT COUNT(*) FROM personalcars"); samp_mysql_query(sql); samp_mysql_store_result(); samp_mysql_fetch_row(row); totalcars = strval(row); for(new idx = 500; idx < MAX_CARS; idx++) { format(sql,sizeof(sql), "SELECT * FROM personalcars WHERE id=%d", idx); samp_mysql_query(sql); samp_mysql_store_result(); if (samp_mysql_num_rows() > 0) { samp_mysql_fetch_row(row); split(row, car, '|'); CarInfo[idx][cSQLID] = strval(car[0]); CarInfo[idx][cModel] = strval(car[1]); CarInfo[idx][cLocationx] = floatstr(car[2]); CarInfo[idx][cLocationy] = floatstr(car[3]); CarInfo[idx][cLocationz] = floatstr(car[4]); CarInfo[idx][cAngle] = floatstr(car[5]); CarInfo[idx][cColorOne] = strval(car[6]); CarInfo[idx][cColorTwo] = strval(car[7]); strmid(CarInfo[idx][cOwner], car[8], 0, strlen(car[8]), 255); strmid(CarInfo[idx][cDescription], car[9], 0, strlen(car[9]), 255); CarInfo[idx][cValue] = strval(car[10]); CarInfo[idx][cOwned] = strval(car[11]); CarInfo[idx][cLock] = strval(car[12]); CarInfo[idx][cMod1] = strval(car[13]); CarInfo[idx][cMod2] = strval(car[14]); CarInfo[idx][cMod3] = strval(car[15]); CarInfo[idx][cMod4] = strval(car[16]); CarInfo[idx][cMod5] = strval(car[17]); CarInfo[idx][cMod6] = strval(car[18]); CarInfo[idx][cMod7] = strval(car[19]); CarInfo[idx][cMod8] = strval(car[20]); CarInfo[idx][cMod9] = strval(car[21]); CarInfo[idx][cMod10] = strval(car[22]); CarInfo[idx][cMod11] = strval(car[23]); CarInfo[idx][cMod12] = strval(car[24]); CarInfo[idx][cMod13] = strval(car[25]); CarInfo[idx][cMod14] = strval(car[26]); CarInfo[idx][cMod15] = strval(car[27]); CarInfo[idx][cMod16] = strval(car[28]); CarInfo[idx][cMod17] = strval(car[29]); CarInfo[idx][cPaintjob] = strval(car[30]); CarInfo[idx][cInsurer] = strval(car[31]); CarInfo[idx][cPanels] = strval(car[32]); CarInfo[idx][cDoors] = strval(car[33]); CarInfo[idx][cLights] = strval(car[34]); CarInfo[idx][cTires] = strval(car[35]); CarInfo[idx][cHealth] = strval(car[36]); idx++; idx = AddStaticVehicleEx(strval(car[1]), floatstr(car[2]), floatstr(car[3]), floatstr(car[4]), floatstr(car[5]), strval(car[6]), strval(car[7]), 60000); } } printf("%d cars loaded from database", totalcars); //samp_mysql_free_result(); return 1; }
I open the server and my gamemode is spawning 500 vehicles at same coordinates ( He is spawning 500 times the first car from PersonalCars table. ).
How can i fix this? I want to add cars in my server without modify any code in .pwn.