Either way, you will need to use a timer to update the proximity or check the player location. Here is a simple script that does basically what you are wanting:
Code:
$ProxDist = 100;
sub EVENT_SPAWN {
$x = $npc->GetX();
$y = $npc->GetY();
$z = $npc->GetZ();
quest::set_proximity($x - $ProxDist, $x + $ProxDist, $y - $ProxDist, $y + $ProxDist, $z - $ProxDist, $z + $ProxDist);
quest::settimer("setprox", 2);
}
sub EVENT_TIMER {
if ($timer eq "setprox") {
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
quest::clear_proximity();
quest::set_proximity($x - $ProxDist, $x + $ProxDist, $y - $ProxDist, $y + $ProxDist, $z - $ProxDist, $z + $ProxDist);
}
}
sub EVENT_ENTER {
quest::FlyMode(2);
}
sub EVENT_EXIT {
quest::FlyMode(0);
}
The only problem with this is that if the player stands in place while the NPC moves out of range and creates a new proximity, it won't remove their flymode because they won't actually be exiting the old or new proximity. Probably the best work-around for this is to do a loop through the client list to do a distance check and remove flymode if they are outside a specified range. You could do that in the same timer as the proximity move so they line up time-wise with each other.