13.12.2011, 15:26
Hey,
Now in right section
I have a little problem with MySQL.
I want to load the vehicles with MySQL and i have a little script.
But there is one problem, the server loads only one Car.
Code:
Can you tell me what is wrong?
Ber912
Now in right section
I have a little problem with MySQL.
I want to load the vehicles with MySQL and i have a little script.
But there is one problem, the server loads only one Car.
Code:
Код:
enum FrakCars { Fraktion, Model, Float:x, Float:y, Float:z, Float:a, Color1, Color2, CarID, } new FrakCarInfo[50][FrakCars];
Код:
public OnGameModeInit() { SetGameModeText("Blank Script"); AddPlayerClass(0, 1244.3230,-2038.6282,59.6752,179.8692, 0, 0, 0, 0, 0, 0); Connect_To_Database(); LoadFrakCars(); }
Код:
stock LoadFrakCars() { new fc; new string[16]; while(fc<50) { format(string, sizeof(string),"%d",fc); FrakCarInfo[fc][Model] = mysql_GetInt("vehicles", "Model", "id", string); FrakCarInfo[fc][x] = mysql_GetFloat("vehicles", "x", "id", string); FrakCarInfo[fc][y] = mysql_GetFloat("vehicles", "y", "id", string); FrakCarInfo[fc][z] = mysql_GetFloat("vehicles", "z", "id", string); FrakCarInfo[fc][a] = mysql_GetFloat("Vehicles", "a", "id", string); FrakCarInfo[fc][Color1] = mysql_GetInt("vehicles", "Color1", "id", string); FrakCarInfo[fc][Color2] = mysql_GetInt("vehicles", "Color2", "id", string); if(FrakCarInfo[fc][Model] >= 400 && FrakCarInfo[fc][Model] <= 611) { FrakCarInfo[fc][CarID] = AddStaticVehicleEx(FrakCarInfo[fc][Model], FrakCarInfo[fc][x], FrakCarInfo[fc][y], FrakCarInfo[fc][z], FrakCarInfo[fc][a], FrakCarInfo[fc][Color1], FrakCarInfo[fc][Color2], -1); } fc++; } return 1; }
Код:
stock mysql_GetInt(Table[], Field[], Where[], Is[]) { new query[128]; mysql_real_escape_string(Table, Table); mysql_real_escape_string(Field, Field); mysql_real_escape_string(Where, Where); mysql_real_escape_string(Is, Is); format(query, 128, "SELECT %s FROM %s WHERE %s = '%s'", Field, Table, Where, Is); mysql_query(query); mysql_store_result(); new sqlint = mysql_fetch_int(); mysql_free_result(); return sqlint; }
Код:
stock Float:mysql_GetFloat(Table[], Field[], Where[], Is[]) { new query[128], Float:sqlfloat; mysql_real_escape_string(Table, Table); mysql_real_escape_string(Field, Field); mysql_real_escape_string(Where, Where); mysql_real_escape_string(Is, Is); format(query, 128, "SELECT %s FROM %s WHERE %s = '%s'", Field, Table, Where, Is); mysql_query(query); mysql_store_result(); mysql_fetch_float(sqlfloat); mysql_free_result(); return sqlfloat; }
Ber912