SA-MP Forums Archive
Reading from file works not perfect.. [NOT SOLVED] - 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: Reading from file works not perfect.. [NOT SOLVED] (/showthread.php?tid=130669)



Reading from file works not perfect.. [NOT SOLVED] - RyDeR` - 27.02.2010

Hi, I'm making a race filterscript but there's an issue..

Checkpoints: >>
Код:
1753.6545 850.6560 9.5190
1568.6921 833.5577 6.3990
1287.6051 905.6605 6.4374
1226.4041 1334.8127 6.3621
1209.0433 1502.7931 6.3621
1263.7335 1732.5851 8.0399
1401.9918 1872.6542 10.3007
1707.2323 1886.4031 10.2967
1728.4037 2053.3477 10.2970
1956.9373 2022.1593 10.2968
2176.9705 2137.1475 10.2968
2349.7729 2179.5166 10.3058
2287.6816 2291.3613 10.3413
2271.7271 2413.7090 10.3006
2189.2878 2325.5537 10.2968
2074.8704 1758.3037 10.2968
2047.5907 1587.5190 10.2968
2061.5239 1531.0094 10.2968
2047.8118 1361.2373 10.2968
2046.0575 861.8326 6.3588
This is the code I'm using in a function (LoadRace) to read the Checkpoints.

Код:
while(fread(ReadFileString, Line, sizeof Line, false))
{
	CP[CPCount][1] = floatstr(strtok(Line, Index));
	CP[CPCount][2] = floatstr(strtok(Line, Index));
	CP[CPCount][3] = floatstr(strtok(Line, Index));
	CPCount++;
}
When I start the race the first RaceCheckpoint will show perfectly but when I take the checkpoint the next checkpoint will locate at 0.0, 0.0, 0.0.

This is the way I'm using to set the checkpoints under my function to start the race: >>

Код:
SetPlayerRaceCheckpoint(playerid, 0, CP[WhichCheckpoint[playerid]][1], CP[WhichCheckpoint[playerid]][2],CP[WhichCheckpoint[playerid]][3], CP[WhichCheckpoint[playerid]+1][1], CP[WhichCheckpoint[playerid]+1][2],CP[WhichCheckpoint[playerid]+1][3], CP_SIZE);
and this under OnPlayerEnterRaceCheckpoint: >>
Код:
	WhichCheckpoint[playerid]++;
	CP[WhichCheckpoint[playerid]][1]++;
	CP[WhichCheckpoint[playerid]][2]++;
	CP[WhichCheckpoint[playerid]][3]++;
	SetPlayerRaceCheckpoint(playerid, 0, CP[WhichCheckpoint[playerid]][1], CP[WhichCheckpoint[playerid]][2],CP[WhichCheckpoint[playerid]][3], CP[WhichCheckpoint[playerid]+1][1], CP[WhichCheckpoint[playerid]+1][2],CP[WhichCheckpoint[playerid]+1][3], CP_SIZE);
What can be the problem?



Regards,


Re: Reading from file works not perfect.. [NOT SOLVED] - Jefff - 27.02.2010

1. Check this in console because its wrong (printf)
Код:
while(fread(ReadFileString, Line, sizeof Line, false))
{
	CP[CPCount][1] = floatstr(strtok(Line, Index));
	CP[CPCount][2] = floatstr(strtok(Line, Index));
	CP[CPCount][3] = floatstr(strtok(Line, Index));
	CPCount++;
}
2. U dont need this
Код:
	CP[WhichCheckpoint[playerid]][1]++;
	CP[WhichCheckpoint[playerid]][2]++;
	CP[WhichCheckpoint[playerid]][3]++;



Re: Reading from file works not perfect.. [NOT SOLVED] - RyDeR` - 27.02.2010

I debugged it and here: >>


So there's something wrong with this.. Only the first one loads.

Код:
while(fread(ReadFileString, Line, sizeof Line, false))
{
	CP[CPCount][1] = floatstr(strtok(Line, Index));
	CP[CPCount][2] = floatstr(strtok(Line, Index));
	CP[CPCount][3] = floatstr(strtok(Line, Index));
	CPCount++;
}
But what? .. I realy dunno what I can do else..


Re: Reading from file works not perfect.. [NOT SOLVED] - Jefff - 27.02.2010

Код:
while(fread(ReadFileString, Line, sizeof Line, false))
{
	Index=0; // :P
	CP[CPCount][1] = floatstr(strtok(Line, Index));
	CP[CPCount][2] = floatstr(strtok(Line, Index));
	CP[CPCount][3] = floatstr(strtok(Line, Index));
	CPCount++;
}



Re: Reading from file works not perfect.. [NOT SOLVED] - RyDeR` - 27.02.2010

LawL you can't belive how much I'm shaming now!
Thanks anyway :P


Re: Reading from file works not perfect.. [NOT SOLVED] - RyDeR` - 27.02.2010

One thing what's wrong with this?

Код:
SetPlayerRaceCheckpoint(playerid, 0, CP[WhichCheckpoint[playerid]][1], CP[WhichCheckpoint[playerid]][2],CP[WhichCheckpoint[playerid]][3], CP[WhichCheckpoint[playerid]+1][1], CP[WhichCheckpoint[playerid]+1][2],CP[WhichCheckpoint[playerid]+1][3], CP_SIZE);
It still does the objects show in 0.0 0.0 0.0 but in debug i have the normal coordinates..


Re: Reading from file works not perfect.. [NOT SOLVED] - Jefff - 27.02.2010

This is deleted?
Код:
	CP[WhichCheckpoint[playerid]][1]++;
	CP[WhichCheckpoint[playerid]][2]++;
	CP[WhichCheckpoint[playerid]][3]++;



Re: Reading from file works not perfect.. [NOT SOLVED] - RyDeR` - 27.02.2010

Jep.


Re: Reading from file works not perfect.. [NOT SOLVED] - Jefff - 27.02.2010

Hm show OnPlayerEnterRaceCheckpoint


Re: Reading from file works not perfect.. [NOT SOLVED] - RyDeR` - 28.02.2010

And the problem is not only OnPlayerEnterRaceCheckpoint also StartRace (Only SetPlayerRaceCheckpoint bugs at 0.0, 0.0, 0.0)

Код:
forward SetupRace(playerid);
public SetupRace(playerid)
{
	SetPlayerPos(playerid, vPos[1], vPos[2], vPos[3]);
	RaceVehicle[playerid] = CreateVehicle(Vehicle, vPos[1], vPos[2], vPos[3], vPos[4], random(126), random(126), (30 * 60));
	PutPlayerInVehicle(playerid, RaceVehicle[playerid], 0);
	TogglePlayerControllable(playerid, false);
	SetPlayerRaceCheckpoint(playerid, 0, CP[WhichCheckpoint[playerid]][1], CP[WhichCheckpoint[playerid]][2], CP[WhichCheckpoint[playerid]][3], CP[WhichCheckpoint[playerid]+1][1], CP[WhichCheckpoint[playerid]+1][2], CP[WhichCheckpoint[playerid]+1][3], CP_SIZE);
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
	WhichCheckpoint[playerid]++;
	SetPlayerRaceCheckpoint(playerid, 0, CP[WhichCheckpoint[playerid]][1], CP[WhichCheckpoint[playerid]][2], CP[WhichCheckpoint[playerid]][3], CP[WhichCheckpoint[playerid]+1][1], CP[WhichCheckpoint[playerid]+1][2], CP[WhichCheckpoint[playerid]+1][3], CP_SIZE);
	return 1;
}