Well basically you can use indexes in the following way:
NPC Code:
if (playerenters||timeout) {
for (this.i=0;this.i<playescount;this.i++) {
/*Here you can always check for a player with for
example a specific flag if he is in a certain position by
for example using if (players[this.i].x==x)*/
}
timeout = 0.05;
}