Reading from file works not perfect.. [NOT SOLVED]
#1

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,
Reply
#2

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]++;
Reply
#3

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..
Reply
#4

Код:
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++;
}
Reply
#5

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

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..
Reply
#7

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

Jep.
Reply
#9

Hm show OnPlayerEnterRaceCheckpoint
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)