Problem with loading from file
#1

Well, I am creating race system and it loading not as it should. Code seems right, but it loads just one line correctly, other lines gives 0.0000. Here is code:

pawn Код:
new Float:RaceCP[20][3];

//loading:
    new stringas[128], stringas2[50], stringas3[256], idx;
    for(new i=0; i<20; i++)
    {
      format(stringas, 256, "cp%d", i);
      stringas3 = dini_Get(stringas2, stringas);
      printf(stringas3);
      RaceCP[i][0] = floatstr(strtok(stringas3, idx, ','));
      RaceCP[i][1] = floatstr(strtok(stringas3, idx, ','));
      RaceCP[i][2] = floatstr(strtok(stringas3, idx, ','));
      printf("%f,%f,%f", RaceCP[i][0], RaceCP[i][1], RaceCP[i][2]);
    }
Coordinates in file:
Код:
cp0=-2579.410644,1120.202270,55.317394
cp1=-2665.157226,1196.118896,55.225852
cp2=-2681.747802,1313.985717,55.225666
cp3=-2681.197509,1517.328002,59.634510
cp4=-2681.197753,1653.391723,66.505981
cp5=-2681.128906,1824.281982,67.704483
cp6=-2680.879150,1940.523071,63.748809
cp7=-2681.165283,2089.499511,55.555252
cp8=-2694.856933,2245.784912,55.225975
cp9=-2739.402587,2378.726318,72.096359
cp10=-2696.027343,2549.967041,76.462959
cp11=-2551.886474,2614.809326,61.099170
cp12=-2355.870117,2634.208984,53.459033
cp13=-1995.088867,2560.949218,55.051868
cp14=-1915.163696,2398.955566,50.248069
cp15=-1777.669311,2185.497558,15.863869
cp16=-1649.173339,2005.287841,18.147781
cp17=-1529.171508,1720.640136,2.388646
cp18=-1317.000000,1698.603881,6.259317
cp19=-1128.431884,1545.092895,21.614116
And output in console:
Код:
[14:52:23] -2579.410644,1120.202270,55.317394
[14:52:23] -2579.410644,1120.202270,55.317394
[14:52:23] -2665.157226,1196.118896,55.225852
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2681.747802,1313.985717,55.225666
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2681.197509,1517.328002,59.634510
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2681.197753,1653.391723,66.505981
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2681.128906,1824.281982,67.704483
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2680.879150,1940.523071,63.748809
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2681.165283,2089.499511,55.555252
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2694.856933,2245.784912,55.225975
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2739.402587,2378.726318,72.096359
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2696.027343,2549.967041,76.462959
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2551.886474,2614.809326,61.099170
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -2355.870117,2634.208984,53.459033
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -1995.088867,2560.949218,55.051868
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -1915.163696,2398.955566,50.248069
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -1777.669311,2185.497558,15.863869
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -1649.173339,2005.287841,18.147781
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -1529.171508,1720.640136,2.388646
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -1317.000000,1698.603881,6.259317
[14:52:23] 0.000000,0.000000,0.000000
[14:52:23] -1128.431884,1545.092895,21.614116
[14:52:23] 0.000000,0.000000,0.000000
Reply
#2

Index should be resets
Код:
	new stringas[128], stringas2[50], stringas3[256], idx;
	for(new i=0; i<20; i++)
	{
		format(stringas, 256, "cp%d", i);
		stringas3 = dini_Get(stringas2, stringas);
		printf(stringas3);
		idx=0; // <===
		RaceCP[i][0] = floatstr(strtok(stringas3, idx, ','));
		RaceCP[i][1] = floatstr(strtok(stringas3, idx, ','));
		RaceCP[i][2] = floatstr(strtok(stringas3, idx, ','));
	}
Reply
#3

Thanks, it works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)