11.03.2016, 13:50
Quote:
For some reason that code always ends up with mission ID 0, which doesn't exist, so it's point is at 0.0 0.0 0.0
But once i remove the mission ID checker so it can be mission id 0, then it's always comes up with mission ID 1 |
Because there shouldn't be an id 0
PHP код:
stock GetNextMissionCheckpoint(playerid) {
#define SIZE 64
#if sizeof mInfo > SIZE
#undef SIZE
#define SIZE sizeof mInfo
#endif
new
count,
p = -1,
tmp[SIZE]
;
while(++p < sizeof mInfo) {
if(mInfo[p][mID] != 0) { // \/ changed second mY to mZ
if(500.0 < GetPlayerDistanceFromPoint(playerid, mInfo[p][mX], mInfo[p][mY], mInfo[p][mZ])) {
tmp[count++] = mInfo[p][mID];
}
}
}
if(count == 0) {
return printf("No mission found!");
}
printf("count %d", count); // add some debug prints
for(new i; i < count; ++i) printf("%d - %d", i, tmp[i]);
p = tmp[random(count)];
format(tmp, sizeof tmp, "Mission ID %i, X: %f, Y: %f, Z: %f", mInfo[p][mID], mInfo[p][mX], mInfo[p][mY], mInfo[p][mZ]);
SendClientMessage(playerid, COLOR_WHITE, tmp);
return p;
}