Neue version:
static Float:cp_coords[][3] = { {XCOORDS, YCOORDS, ZCOORDS},
... };
new statePlayerCP[MAX_PLAYERS], bool:isPlayerStreamCP[MAX_PLAYERS], bool:incp[MAX_PLAYERS], Float:cpDist[MAX_PLAYERS];
#define MAX_DISTANCE_BETWEEN_CPS 20.0
#define MAX_SIZE_CP 5.0
forward GlobalTimer();
stock Float:GetDistance(Float:x, Float:xx, Float:y, Float:yy, Float:z, Float:zz)
return floatsqroot(floatpower(floatabs(x - xx), 2) + floatpower(floatabs(y - yy), 2) + floatpower(floatabs(z - zz), 2));
public OnGameModeInit() {
SetTimer("GlobalTimer", 1000, 1);
return 1;
}
public GlobalTimer() {
new Float:dist = MAX_DISTANCE_BETWEEN_CPS, Float:tmpdist, Float:each[3];
for(new i = 0; i < MAX_PLAYERS; i++) {
if(isPlayerStreamCP[i] == false) {
GetPlayerPos(i, each[0], each[1], each[2]);
statePlayerCP[i] = -1;
for(new j = 0; j < sizeof cp_coords; j++) {
tmpdist = GetDistance(cp_coords[j][0], each[0], cp_coords[j][1], each[1], cp_coords[j][2], each[2]);
if(tmpdist < dist) {
statePlayerCP[i] = j;
dist = tmpdist;
}
}
if(statePlayerCP[i] != -1) {
isPlayerStreamCP[i] = true;
cpDist[i] = dist;
SetPlayerCheckpoint(i, cp_coords[statePlayerCP[i]][0], cp_coords[statePlayerCP[i]][1], cp_coords[statePlayerCP[i]][2], MAX_SIZE_CP);
}
} else if(isPlayerStreamCP[i] == true && incp[i] == false) {
GetPlayerPos(i, each[0], each[1], each[2]);
if(cpDist[i] > GetDistance(cp_coords[statePlayerCP[i]][0], each[0], cp_coords[statePlayerCP[i]][1], each[1], cp_coords[statePlayerCP[i]][2], each[2])) {
DisablePlayerCheckpoint(i);
isPlayerStreamCP[i] = false;
}
}
}
}
public OnPlayerEnterCheckpoint(playerid) {
switch(statePlayerCP[playerid]) {
case 0: {
/* tu was z.b. das: */
SendClientMessage(playerid, 0xFF6900AA, "CP 1!");
} case 1: {
SendClientMessage(playerid, 0xFF0000AA, "CP 2!");
}
/* ... */
}
incp[playerid] = true;
return 1;
}
public OnPlayerLeaveCheckpoint(playerid) {
incp[playerid] = false;
return 1;
}
Sollte das Blinken entfernen.