11.03.2016, 02:14
Normally you would do it like that, create an array, save all ids and use random afterwards
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];
}
}
}
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;
}