enum vehicleinfo { ID, Status, Plate[10], Model, FractionID, JobID, Noob, Locked, Towed, Tunable, Float:X1, Float:Y1, Float:Z1, Float:A1, Float:X2, Float:Y2, Float:Z2, Float:A2, Owner[30], Key1[30], Key2[30], Color1, Color2, Paintjob, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 };
LoadVehicles() { new query[512], string[512]; for(new i = 1; i < MAX_VEHICLES; i++) { format(query,512, "SELECT * FROM Vehicle WHERE ID = '%d'", i); mysql_query(query); mysql_store_result(); if(mysql_num_rows() > 0) { mysql_fetch_row(string); mysql_free_result(); printf("%s", string); sscanf(string, "e<p<|>dds[10]dddddddffffffffs[30]s[30]s[30]ddddddddddddddddd>", Vehicle[i]); if(Vehicle[i][Status]) { new vehicleid = -1; new respawntime = -1; if(Vehicle[i][Noob]) { respawntime = 600000; } if(!Vehicle[i][Towed]) { printf("Model: %d FractionID: %d JobID: %d Noob: %d Locked: %d Towed: %d Tunable: %d", Vehicle[i][Model], Vehicle[i][FractionID], Vehicle[i][JobID], Vehicle[i][Noob], Vehicle[i][Locked], Vehicle[i][Towed], Vehicle[i][Tunable]); printf("X1: %f Y1: %f Z1: %f A1: %f ", Vehicle[i][X1], Vehicle[i][Y1], Vehicle[i][Z1] + 1, Vehicle[i][A1]); vehicleid = CreateVehicle(Vehicle[i][Model], Vehicle[i][X1], Vehicle[i][Y1], Vehicle[i][Z1] + 1, Vehicle[i][A1], Vehicle[i][Color1], Vehicle[i][Color2], respawntime); printf("%d", vehicleid); } else { printf("Towed"); vehicleid = CreateVehicle(Vehicle[i][Model], Vehicle[i][X2], Vehicle[i][Y2], Vehicle[i][Z1] + 1, Vehicle[i][A2], Vehicle[i][Color1], Vehicle[i][Color2], respawntime); } SetVehicleNumberPlate(vehicleid, Vehicle[i][Plate]); VehicleID[vehicleid] = Vehicle[i][ID]; SetVehicleConfiguration(vehicleid); } } } }
Wrong output: "Nan (At position X1 we have an invalid value)", "1126.530029 (X1, but at position of Y1)", "-1451.319946 (Y1, but at position of Z1)", "15.516900 (Z1, but at position of A1")
"1126.53 (X1)", "-1452.32 (Y1)", "15.5169 (Z1)", "351.84 "A1"
[23:36:23] 1|1|Terra|596|44|55|66|77|0|99|1126.53|-1452.32|15.5169|351.84|0|0|0|0|Keiner|Keiner|Keiner|0|1|-1|0|0|0|0|0|0|0|0|0|0|0|0|0|0 [23:36:23] Model: 596 FractionID: 44 JobID: 55 Noob: 66 Locked: 77 Towed: 0 Tunable: 99 [23:36:23] X1: NaN Y1: 1126.530029 Z1: -1451.319946 A1: 15.516900 [23:36:23] 1
for(new i = 1; i < MAX_VEHICLES; i++)
{
format(query,512, "SELECT * FROM Vehicle WHERE ID = '%d'", i);
sscanf(string, "p<|>dds[10]dddddddffffffffs[24]s[24]s[24]ddddddddddddddddd", Vehicle[i][ID], Vehicle[i][Status], Vehicle[i][Plate], Vehicle[i][Model], Vehicle[i][FractionID], Vehicle[i][JobID], Vehicle[i][Noob], Vehicle[i][Locked], Vehicle[i][Towed], Vehicle[i][Tunable], Vehicle[i][X1], Vehicle[i][Y1], Vehicle[i][Z1], Vehicle[i][A1], Vehicle[i][X2], Vehicle[i][Y2], Vehicle[i][Z2], Vehicle[i][A2], Vehicle[i][Owner], Vehicle[i][Key1], Vehicle[i][Key2], Vehicle[i][Color1], Vehicle[i][Color2], Vehicle[i][Paintjob], Vehicle[i][T0], Vehicle[i][T1], Vehicle[i][T2], Vehicle[i][T3], Vehicle[i][T4], Vehicle[i][T5], Vehicle[i][T6], Vehicle[i][T7], Vehicle[i][T8], Vehicle[i][T9], Vehicle[i][T10], Vehicle[i][T11], Vehicle[i][T12], Vehicle[i][T13]);
sscanf(string, "e<p<|>dds[10]dddddddffffffffs[30]s[30]s[30]ddddddddddddddddd>", Vehicle[i]);
new Vehicle[MAX_VEHICLES][vehicleinfo];
sscanf(string, "p<|>e<dds[10]dddddddffffffffs[30]s[30]s[30]ddddddddddddddddd>", Vehicle[i]);
The old version will still work, but it will give a warning. Enum specifications can include delimiters, and is the only time "<>"s are contained in other "<>"s: pawn Code: sscanf("1 12.0 Bob,c", "e<ifp<,>s[32]c>", var); Note that the delimiter will remain in effect after the enum is complete. |