SA-MP Forums Archive
cars.cfg is not loading for some reason? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: cars.cfg is not loading for some reason? (/showthread.php?tid=236565)



cars.cfg is not loading for some reason? - Ferrari123 - 07.03.2011

I'm taking a dealership from LARP and I've put it into my script successfully but for some reason, when I go in game, the cars aren't there. I've put all the proper functions of loading the dealership, they just don't show up. Has anyone had the same problem or can help me? There are the ones that are supposed to open it.


Code:
public LoadCar()
{
	new arrCoords[13][64];
	new strFromFile2[256];
	new File: file = fopen("cars.cfg", io_read);
	if (file)
	{
		new idx = 184;
		while (idx < sizeof(CarInfo))
		{
			fread(file, strFromFile2);
			split(strFromFile2, arrCoords, ',');
			CarInfo[idx][cModel] = strval(arrCoords[0]);
			CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
			CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
			CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
			CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
			CarInfo[idx][cColorOne] = strval(arrCoords[5]);
			CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
			strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
			strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
			CarInfo[idx][cValue] = strval(arrCoords[9]);
			CarInfo[idx][cLicense] = strval(arrCoords[10]);
			CarInfo[idx][cOwned] = strval(arrCoords[11]);
			CarInfo[idx][cLock] = strval(arrCoords[12]);
			printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
			idx++;
		}
	}
	return 1;
}

public SaveCarCoords()
{
	new idx;
	new File: file2;
	while (idx < sizeof(CarInfo))
	{
	    new coordsstring[256];
	    format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d\n",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo]);
		if(idx == 0)
		{
			file2 = fopen("cars.cfg", io_write);
		}
		else
		{
			file2 = fopen("cars.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	return 1;
}
Code:
public OnPropUpdate()
{

	new idx;
	new File: file2;
 	while (idx < sizeof(CarInfo))
	{
	    new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d\n",
		CarInfo[idx][cModel],//
		CarInfo[idx][cLocationx],//
		CarInfo[idx][cLocationy],//
		CarInfo[idx][cLocationz],//
		CarInfo[idx][cAngle],//
		CarInfo[idx][cColorOne],//
		CarInfo[idx][cColorTwo],//
		CarInfo[idx][cOwner],//
		CarInfo[idx][cDescription],//
		CarInfo[idx][cValue],//
		CarInfo[idx][cLicense],//
		CarInfo[idx][cOwned],//
		CarInfo[idx][cLock]);
		if(idx == 184)
		{
			file2 = fopen("cars.cfg", io_write);
		}
		else
		{
			file2 = fopen("cars.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	return 1;
}
Code:
public OnGameModeInit()
{
    minigameclose = 1;
    MINIGAME = Create3DTextLabel("{00D0FA}Mini Game Center\n{FA002A}CLOSE",0x008080FF,2695.5837,-1704.5444,11.8438,10.0, 0);
    ManualVehicleEngineAndLights();
	DisableInteriorEnterExits();
	LoadCar();



Re: cars.cfg is not loading for some reason? - Stigg - 07.03.2011

Can we see the script ? People will help, but need to see where your going wrong.


Re: cars.cfg is not loading for some reason? - Davz*|*Criss - 07.03.2011

Right


Re: cars.cfg is not loading for some reason? - Ferrari123 - 07.03.2011

Anyone?


Re: cars.cfg is not loading for some reason? - antsolen - 11.08.2011

I got same problem , you fixed that ?