NPC Code:
if (playerenters) {
for (command1; flag; command2) {
Stuff;
}
}
If you run that in a script, command1 will be run, then while flag is true, stuff and command2 will be run. It would be the same as
NPC Code:
if (playerenters( {
command1;
while (flag) {
Stuff;
command2;
}
}
An example for moving a NPC:
NPC Code:
if (whatever) {
setcharani walk,;
for (this.destx = x+5; x<this.destx; x+= 0.5) {
sleep 0.05;
}
setcharani idle,;
}
Or killing all the policemen:
NPC Code:
if (weaponfired) {
for (i=0; i<playerscount; i++) {
if (strequals(#g(i),Police)) hitplayer i,40,x,y;
}
}