[MYSQL] - Load veh
#1

Well, I'm trying to load vehicles with the code below but it's not working, it seeming to me all is correct

Код:
public OnGameModeInit()
{
	mysql_function_query(g_iHandle, "SELECT * FROM `srv_cars`", true, "LoadCarSystem", "");
}
Код:
public LoadCarSystem()
{
	static
	    rows,
	    fields,
		str[128];

	cache_get_data(rows, fields, g_iHandle);

	for (new i = 0; i < rows; i ++) if (i < MAX_VEHICLES)
	{
	    CarSystem[i][cCarID] = cache_get_field_int(i, "CarID");
	    CarSystem[i][cModel] = cache_get_field_int(i, "Model");
		CarSystem[i][cEssence] = cache_get_field_int(i, "Essence");
        cache_get_row(i, 1, CarSystem[i][cX], g_iHandle, 128 );
        cache_get_row(i, 1, CarSystem[i][cY], g_iHandle, 128 );
        cache_get_row(i, 1, CarSystem[i][cZ], g_iHandle, 128 );
		cache_get_row(i, 1, CarSystem[i][cAngle], g_iHandle, 128 );
        CarSystem[i][cColor1] = cache_get_field_int(i, "Color1");
       	CarSystem[i][cColor2] = cache_get_field_int(i, "Color2");
       	CarSystem[i][cKM] = cache_get_field_int(i, "KM");
       	CarSystem[i][cObjective] = cache_get_field_int(i, "Objective");
       	CarSystem[i][cDoorsLocked] = cache_get_field_int(i, "DoorsLocked");
       	CarSystem[i][cVehicleType] = cache_get_field_int(i, "VehicleType");
        cache_get_field_content(i, "Plaque", CarSystem[i][cPlaque], g_iHandle, 32);
   	    CarSystem[i][cVehicleMaterials] = cache_get_field_int(i, "VehicleMaterials");
   	    CarSystem[i][cVehicleCrack] = cache_get_field_int(i, "VehicleCrack");
   	    CarSystem[i][cVehiclePot] = cache_get_field_int(i, "VehiclePot");
   	    CarSystem[i][cJantes] = cache_get_field_int(i, "Jantes");
   	    CarSystem[i][cMetre] = cache_get_field_int(i, "Metre");
   	    CarSystem[i][cVehicleHealth] = cache_get_field_int(i, "VehicleHealth");
    	CarSystem[i][cVehicleAlarm] = cache_get_field_int(i, "VehicleAlarm");
	    CarSystem[i][cVehicleOwned] = cache_get_field_int(i, "VehicleOwned");
	    CarSystem[i][cDescription] = cache_get_field_int(i, "Description");
	    cache_get_field_content(i, "Owner", CarSystem[i][cOwner], g_iHandle, 32);
     	CarSystem[i][cNitro] = cache_get_field_int(i, "Nitro");
	    CarSystem[i][cPaintJob] = cache_get_field_int(i, "PaintJob");
	    CarSystem[i][cLoad] = cache_get_field_int(i, "Load");
	    CarSystem[i][cVehINT] = cache_get_field_int(i, "VehINT");
	    CarSystem[i][cVehWorld] = cache_get_field_int(i, "VehWorld");
	    CarSystem[i][cHydro] = cache_get_field_int(i, "Hydro");
	    CarSystem[i][cPimped] = cache_get_field_int(i, "Pimped");
	    CarSystem[i][cPerma] = cache_get_field_int(i, "Perma");
	    CarSystem[i][cRank] = cache_get_field_int(i, "Rank");
	    CarSystem[i][cPrice] = cache_get_field_int(i, "Price");
	    CarSystem[i][cSpoiler] = cache_get_field_int(i, "Spoiler");
	    CarSystem[i][cFbumper] = cache_get_field_int(i, "Fbumper");
	    CarSystem[i][cRbumper] = cache_get_field_int(i, "Rbumper");
	    SetVehicleHealth(i,CarSystem[i][cVehicleHealth]);
	    ChangeVehicleColor(i,CarSystem[i][cColor1], CarSystem[i][cColor2]);
	    ChangeVehiclePaintjob(i,CarSystem[i][cPaintJob]);
	    SetVehicleNumberPlate(i,CarSystem[i][cPlaque]);
	    AddVehicleComponent(i,CarSystem[i][cJantes]);
     	CreateVehicle(CarSystem[i][cModel],CarSystem[i][cX],CarSystem[i][cY],CarSystem[i][cZ],CarSystem[i][cAngle],CarSystem[i][cColor1],CarSystem[i][cColor2], -1);

	}
        printf("Loading Vehicles");
	return 1;
}
Reply
#2

Any error codes? Please provide us with your log-file .
Reply
#3

No, there's no error
log-file :
[12:42:58] Number of vehicle models: 0
[12:42:58] Loading Vehicles (I don't know why it show after the number of vehicle ....)
Reply
#4

Please I need help ..
Reply
#5

what is problem the values are not saving?
Reply
#6

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
what is problem the values are not saving?
Saving is working good, I have problem with loading, I have already vehicles in DataBase, but It doesn't load, If you want you can see the picture above

Number of vehicle models: 0

No loading ...
Reply
#7

Please be more detailed.

Is there any vehicle (from those in db) in-game?
Does the message "Loading Vehicles" appear in the console?
Is it because the number of vehicle models is 0? That's nothing to concern because you have to keep in mind that there's delay while selecting the data, retrieving the data using cache functions and creating the vehicles.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Please be more detailed.

Is there any vehicle (from those in db) in-game?
Does the message "Loading Vehicles" appear in the console?
Is it because the number of vehicle models is 0? That's nothing to concern because you have to keep in mind that there's delay while selecting the data, retrieving the data using cache functions and creating the vehicles.
Q1 : Yes, please see the picture
Q2: Yes it appears
Q3: Yes this is one of the problem + vehicles spawn with incorrect position (please see the picture)

The problem is the vehicles spawn with incorrect position and the number of vehicle models is 0, so that's means is not correctly spawned
Reply
#9

pawn Код:
cache_get_row(i, 1, CarSystem[i][cX], g_iHandle, 128 );
cache_get_row(i, 1, CarSystem[i][cY], g_iHandle, 128 );
cache_get_row(i, 1, CarSystem[i][cZ], g_iHandle, 128 );
cache_get_row(i, 1, CarSystem[i][cAngle], g_iHandle, 128 );
Coordinates are floats but you stored them like they're strings and you don't use floatstr either. Use cache_get_field_float instead for those 4.
Reply
#10

Position is solved, but others values still not working ...

Код:
public LoadCarSystem()
{
	static
	    rows,
	    fields,
		str[128];
	cache_get_data(rows, fields, g_iHandle);

	for (new i = 0; i < rows; i ++) if (i < MAX_VEHICLES)
	{
	    CarSystem[i][cCarID] = cache_get_field_int(i, "CarID");
	    CarSystem[i][cModel] = cache_get_field_int(i, "Model");
		CarSystem[i][cEssence] = cache_get_field_int(i, "Essence");
        CarSystem[i][cX] = cache_get_field_float(i, "PosX");
        CarSystem[i][cY] = cache_get_field_float(i, "PosY");
        CarSystem[i][cZ] = cache_get_field_float(i, "PosZ");
        CarSystem[i][cAngle] = cache_get_field_float(i, "Angle");
        CarSystem[i][cColor1] = cache_get_field_int(i, "Color1");
       	CarSystem[i][cColor2] = cache_get_field_int(i, "Color2");
       	CarSystem[i][cKM] = cache_get_field_int(i, "KM");
       	CarSystem[i][cObjective] = cache_get_field_int(i, "Objective");
       	CarSystem[i][cDoorsLocked] = cache_get_field_int(i, "DoorsLocked");
       	CarSystem[i][cVehicleType] = cache_get_field_int(i, "VehicleType");
        cache_get_field_content(i, "Plaque", CarSystem[i][cPlaque], g_iHandle, 32);
   	    CarSystem[i][cVehicleMaterials] = cache_get_field_int(i, "VehicleMaterials");
   	    CarSystem[i][cVehicleCrack] = cache_get_field_int(i, "VehicleCrack");
   	    CarSystem[i][cVehiclePot] = cache_get_field_int(i, "VehiclePot");
   	    CarSystem[i][cJantes] = cache_get_field_int(i, "Jantes");
   	    CarSystem[i][cMetre] = cache_get_field_int(i, "Metre");
   	    CarSystem[i][cVehicleHealth] = cache_get_field_int(i, "VehicleHealth");
    	CarSystem[i][cVehicleAlarm] = cache_get_field_int(i, "VehicleAlarm");
	    CarSystem[i][cVehicleOwned] = cache_get_field_int(i, "VehicleOwned");
	    cache_get_field_content(i, "Description", CarSystem[i][cDescription], g_iHandle, 64);
	    cache_get_field_content(i, "Owner", CarSystem[i][cOwner], g_iHandle, 255);
     	CarSystem[i][cNitro] = cache_get_field_int(i, "Nitro");
	    CarSystem[i][cPaintJob] = cache_get_field_int(i, "PaintJob");
	    CarSystem[i][cLoad] = cache_get_field_int(i, "Load");
	    CarSystem[i][cVehINT] = cache_get_field_int(i, "VehINT");
	    CarSystem[i][cVehWorld] = cache_get_field_int(i, "VehWorld");
	    CarSystem[i][cHydro] = cache_get_field_int(i, "Hydro");
	    CarSystem[i][cPimped] = cache_get_field_int(i, "Pimped");
	    CarSystem[i][cPerma] = cache_get_field_int(i, "Perma");
	    CarSystem[i][cRank] = cache_get_field_int(i, "Rank");
	    CarSystem[i][cPrice] = cache_get_field_int(i, "Price");
	    CarSystem[i][cSpoiler] = cache_get_field_int(i, "Spoiler");
	    CarSystem[i][cFbumper] = cache_get_field_int(i, "Fbumper");
	    CarSystem[i][cRbumper] = cache_get_field_int(i, "Rbumper");
	    SetVehicleHealth(i,CarSystem[i][cVehicleHealth]);
	    ChangeVehicleColor(i,CarSystem[i][cColor1], CarSystem[i][cColor2]);
	    ChangeVehiclePaintjob(i,CarSystem[i][cPaintJob]);
	    SetVehicleNumberPlate(i,CarSystem[i][cPlaque]);
	    AddVehicleComponent(i,CarSystem[i][cJantes]);
     	CreateVehicle(CarSystem[i][cModel],CarSystem[i][cX],CarSystem[i][cY],CarSystem[i][cZ],CarSystem[i][cAngle],CarSystem[i][cColor1],CarSystem[i][cColor2], -1);
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)