i can't save or load any car +REP
#1

can some one told me what's wrong?

the code in the cars.cfg
Код:
411,2716.7959,-1483.2106,30.1314,251.6073,-1,-1,404,1629.8917,-1743.1121,13.2878,141.1261,-1,-1,421,1565.4016,-1713.8560,5.7113,236.5188,-1,-1
Код:
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] 0 0.000000 0.000000 0.000000 0.000000 45 45
[01:37:52] Number of vehicle models: 0
Код:
forward loadcar();
public loadcar()
{
	new arrCoords[7][64];
	new strFromFile2[256];
	new File: file = fopen("cars.cfg", io_read);
	if (file)
	{
		new idx;
		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]);
            CreateVehicle(cModel,Float:cLocationx,Float:cLocationy,Float:cLocationz,Float:cAngle,cColorOne,cColorTwo,99999);
            printf("%d %f %f %f %f %d %d",arrCoords[0],arrCoords[1],arrCoords[2],arrCoords[3],arrCoords[4],arrCoords[5],arrCoords[6]);
			idx++;
		}
		fclose(file);
	}
	return 1;
}
forward savecar();
public savecar()
{
new idx;
new File: file2;
for (new i = 0; i < MAX_VEHICLES; i++)
{
   new Float:vX, Float:vY, Float:vZ, Float:vA;
   new m = GetVehicleModel(i);
   GetVehiclePos(i, vX, vY, vZ);
   GetVehicleZAngle(i, vA);
   GetVehicleModel(i);
   while (idx < sizeof(CarInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d",
		CarInfo[idx][cModel] = m,
		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;
}
Reply
#2

Use
pawn Код:
TEXT
tags ([ pawn ] TEXT [/ pawn] without the spaces) and I might take a look at it.
Reply
#3

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Use
pawn Код:
TEXT
tags ([ pawn ] TEXT [/ pawn] without the spaces) and I might take a look at it.
it's ok now
Reply
#4

Jochemd took meh answer )
But yea, I was going to say that and it should of worked which it did.
Reply
#5

Quote:
Originally Posted by RedWingz
Посмотреть сообщение
Jochemd took meh answer )
But yea, I was going to say that and it should of worked which it did.
but not car have been create
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)