Okay.
Enum:
Код:
enum carInfo
{
vID,
vModel,
Float:vPosX,
Float:vPosY,
Float:vPosZ,
Float:vRot,
vCol1,
vCol2
};
new cInfo[MAX_VEHICLES][carInfo];
Here the vehicle loading (this is works fine.):
Код:
public OnQueryFinish(resultid, extraid, ConnectionHandle)
{
new num_rows, num_fields;
if(resultid != THREAD_NO_RESULT)
{
cache_get_data(num_rows, num_fields);
}
switch(resultid)
{
case THREAD_LOAD_VEHICLES:
{
if(num_rows)
{
for(new v; v < MAX_VEHICLES; v ++)
{
cInfo[v][vID] = cache_get_field_content_int(v,"ID",dbhandle);
cInfo[v][vModel] = cache_get_field_content_int(v,"VehModel",dbhandle);
cInfo[v][vPosX] = cache_get_field_content_float(v,"VehX",dbhandle);
cInfo[v][vPosY] = cache_get_field_content_float(v,"VehY",dbhandle);
cInfo[v][vPosZ] = cache_get_field_content_float(v,"VehZ",dbhandle);
cInfo[v][vRot] = cache_get_field_content_float(v,"VehRot",dbhandle);
cInfo[v][vCol1] = cache_get_field_content_int(v,"VehCol1",dbhandle);
cInfo[v][vCol2] = cache_get_field_content_int(v,"VehCol2",dbhandle);
CreateVehicle(cInfo[v][vModel],cInfo[v][vPosX],cInfo[v][vPosY],cInfo[v][vPosZ],cInfo[v][vRot],cInfo[v][vCol1],cInfo[v][vCol2],-1);
vehicleCount++;
printf("Cars Loaded: %d", v);
}
}
}
}
return 1;
}
And here the vehicle saving:
Код:
CMD:vehicles(playerid, params[])
{
VehicleSaveAll();
return 1;
}
stock VehicleSaveAll()
{
new str[128];
new query[1024];
for(new v; v < MAX_VEHICLES; v ++)
{
GetVehiclePos(v,cInfo[v][vPosX],cInfo[v][vPosY],cInfo[v][vPosZ]);
GetVehicleZAngle(v, cInfo[v][vRot]);
format(query,sizeof(query),"UPDATE sveh SET VehX='%f',VehY='%f',VehZ='%f',VehRot='%f' WHERE ID='%d'",cInfo[v][vPosX],cInfo[v][vPosY],cInfo[v][vPosZ],cInfo[v][vRot],cInfo[v][vID]);
mysql_function_query(dbhandle,query,true,"","");
format(str, sizeof(str),"VID: %d POS: %f %f %f",cInfo[v][vID],cInfo[v][vPosX],cInfo[v][vPosY],cInfo[v][vPosZ]);
SendClientMessageToAll(COLOR_WHITE,str);
printf("Cars saved: %d", cInfo[v][vID]);
}
return 1;
}