Buggy car loading // HELP ME!!
#1

Hello guys, when it comes to saving I got to the database and saved it right, but at the time of loading the last two functions (pnomefun and carPlaca) is equal, eg: The car ID 1 board is A, the car plate ID 2 will be A also after loading.

Only the functions "pnomefun" and "carPlaca" are the same.
Код:
forward Car_Load();
public Car_Load()
{
	static
	    rows,
	    fields,
		str[128];

	cache_get_data(rows, fields, g_iHandle);

	for (new i = 0; i < rows; i ++) if (i < MAX_DYNAMIC_CARS)
	{
	    CarData[i][carExists] = true;
	    CarData[i][carID] = cache_get_field_int(i, "carID");
	    CarData[i][carModel] = cache_get_field_int(i, "carModel");
	    CarData[i][carOwner] = cache_get_field_int(i, "carOwner");
	    CarData[i][carPos][0] = cache_get_field_float(i, "carPosX");
	    CarData[i][carPos][1] = cache_get_field_float(i, "carPosY");
	    CarData[i][carPos][2] = cache_get_field_float(i, "carPosZ");
	    CarData[i][carPos][3] = cache_get_field_float(i, "carPosR");
	    CarData[i][carColor1] = cache_get_field_int(i, "carColor1");
	    CarData[i][carColor2] = cache_get_field_int(i, "carColor2");
	    CarData[i][carPaintjob] = cache_get_field_int(i, "carPaintjob");
	    CarData[i][carLocked] = cache_get_field_int(i, "carLocked");
	    CarData[i][carImpounded] = cache_get_field_int(i, "carImpounded");
	    CarData[i][carImpoundPrice] = cache_get_field_int(i, "carImpoundPrice");
        CarData[i][carFaction] = cache_get_field_int(i, "carFaction");
        CarData[i][carSiren] = cache_get_field_int(i, "carSiren");

        cache_get_field_content(0, "nomefun", CarData[i][pnomefun], g_iHandle, 128);
        cache_get_field_content(0, "carPlaca", CarData[i][carPlaca], g_iHandle, 128);

		for (new j = 0; j < 14; j ++)
		{
		    if (j < 5)
		    {
		        format(str, sizeof(str), "carWeapon%d", j + 1);
		        CarData[i][carWeapons][j] = cache_get_field_int(i, str);

		        format(str, sizeof(str), "carAmmo%d", j + 1);
		        CarData[i][carAmmo][j] = cache_get_field_int(i, str);
	        }
	        format(str, sizeof(str), "carMod%d", j + 1);
	        CarData[i][carMods][j] = cache_get_field_int(i, str);
	    }
	    Car_Spawn(i);
	}
	for (new i = 0; i < MAX_DYNAMIC_CARS; i ++) if (CarData[i][carExists]) {
		format(str, sizeof(str), "SELECT * FROM `carstorage` WHERE `ID` = '%d'", CarData[i][carID]);

		mysql_tquery(g_iHandle, str, "OnLoadCarStorage", "d", i);
	}
	return 1;
}
I hope you can help me, thank you all.
Sorry about my English!
Reply
#2

Quote:
Originally Posted by Derritee1001
Посмотреть сообщение
Hello guys, when it comes to saving I got to the database and saved it right, but at the time of loading the last two functions (pnomefun and carPlaca) is equal, eg: The car ID 1 board is A, the car plate ID 2 will be A also after loading.

Only the functions "pnomefun" and "carPlaca" are the same.
Код:
forward Car_Load();
public Car_Load()
{
	static
	    rows,
	    fields,
		str[128];

	cache_get_data(rows, fields, g_iHandle);

	for (new i = 0; i < rows; i ++) if (i < MAX_DYNAMIC_CARS)
	{
	    CarData[i][carExists] = true;
	    CarData[i][carID] = cache_get_field_int(i, "carID");
	    CarData[i][carModel] = cache_get_field_int(i, "carModel");
	    CarData[i][carOwner] = cache_get_field_int(i, "carOwner");
	    CarData[i][carPos][0] = cache_get_field_float(i, "carPosX");
	    CarData[i][carPos][1] = cache_get_field_float(i, "carPosY");
	    CarData[i][carPos][2] = cache_get_field_float(i, "carPosZ");
	    CarData[i][carPos][3] = cache_get_field_float(i, "carPosR");
	    CarData[i][carColor1] = cache_get_field_int(i, "carColor1");
	    CarData[i][carColor2] = cache_get_field_int(i, "carColor2");
	    CarData[i][carPaintjob] = cache_get_field_int(i, "carPaintjob");
	    CarData[i][carLocked] = cache_get_field_int(i, "carLocked");
	    CarData[i][carImpounded] = cache_get_field_int(i, "carImpounded");
	    CarData[i][carImpoundPrice] = cache_get_field_int(i, "carImpoundPrice");
        CarData[i][carFaction] = cache_get_field_int(i, "carFaction");
        CarData[i][carSiren] = cache_get_field_int(i, "carSiren");

        cache_get_field_content(0, "nomefun", CarData[i][pnomefun], g_iHandle, 128);
        cache_get_field_content(0, "carPlaca", CarData[i][carPlaca], g_iHandle, 128);

		for (new j = 0; j < 14; j ++)
		{
		    if (j < 5)
		    {
		        format(str, sizeof(str), "carWeapon%d", j + 1);
		        CarData[i][carWeapons][j] = cache_get_field_int(i, str);

		        format(str, sizeof(str), "carAmmo%d", j + 1);
		        CarData[i][carAmmo][j] = cache_get_field_int(i, str);
	        }
	        format(str, sizeof(str), "carMod%d", j + 1);
	        CarData[i][carMods][j] = cache_get_field_int(i, str);
	    }
	    Car_Spawn(i);
	}
	for (new i = 0; i < MAX_DYNAMIC_CARS; i ++) if (CarData[i][carExists]) {
		format(str, sizeof(str), "SELECT * FROM `carstorage` WHERE `ID` = '%d'", CarData[i][carID]);

		mysql_tquery(g_iHandle, str, "OnLoadCarStorage", "d", i);
	}
	return 1;
}
I hope you can help me, thank you all.
Sorry about my English!
There's a loop so instead of
Код:
cache_get_field_content(0, "nomefun", CarData[i][pnomefun], g_iHandle, 128);
cache_get_field_content(0, "carPlaca", CarData[i][carPlaca], g_iHandle, 128);
You need to do
Код:
cache_get_field_content(i, "nomefun", CarData[i][pnomefun], g_iHandle, 128);
cache_get_field_content(i, "carPlaca", CarData[i][carPlaca], g_iHandle, 128);
Reply
#3

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
There's a loop so instead of
Код:
cache_get_field_content(0, "nomefun", CarData[i][pnomefun], g_iHandle, 128);
cache_get_field_content(0, "carPlaca", CarData[i][carPlaca], g_iHandle, 128);
You need to do
Код:
cache_get_field_content(i, "nomefun", CarData[i][pnomefun], g_iHandle, 128);
cache_get_field_content(i, "carPlaca", CarData[i][carPlaca], g_iHandle, 128);
Thank you so much, man!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)