19.06.2011, 02:31
The reason it is not saving the information after the dot(.) is because you are using the strval function to retrieve floats. strval saves the string as an integer. Try using the function floatstr for your floats instead. That should read the string and save them as floats. You can see an example of it in action in the wiki here: https://sampwiki.blast.hk/wiki/Floatstr
Also, if the value you are retrieving from the database is to be stored as a string (which it looks like your Plate should be), you can store it into a string variable using the format function.
With these changes, your code should look something like this:
Give that a go and see if you get it any closer to working. Good luck!
Also, if the value you are retrieving from the database is to be stored as a string (which it looks like your Plate should be), you can store it into a string variable using the format function.
With these changes, your code should look something like this:
pawn Код:
LoadVehicle()
{
new query[2048];
Result = db_query(USERDB,"SELECT * FROM `Vehicles`");
for(new a;a<db_num_rows(Result);a++)
{
db_get_field_assoc(Result,"Model",query,sizeof(query));
V_Data[a][Model]=strval(query);
db_get_field_assoc(Result,"Plate",query,sizeof(query));
format(V_Data[a][Plate], sizeof(V_Data[a][Plate]), "%s", query);
db_get_field_assoc(Result,"PosX",query,sizeof(query));
V_Data[a][vPosX]=floatstr(query);
db_get_field_assoc(Result,"PosY",query,sizeof(query));
V_Data[a][vPosY]=floatstr(query);
db_get_field_assoc(Result,"PosZ",query,sizeof(query));
V_Data[a][vPosZ]=floatstr(query);
db_get_field_assoc(Result,"Rot",query,sizeof(query));
V_Data[a][vRot]=floatstr(query);
V_Data[a][ID] = AddStaticVehicleEx(V_Data[a][Model],V_Data[a][vPosX],V_Data[a][vPosY],V_Data[a][vPosZ],V_Data[a][vRot],1,1,-1);
SetVehicleNumberPlate(V_Data[a][ID],V_Data[a][Plate]);
db_next_row(Result);
}
return 1;
}