If you style your script properly you'll see the following..
PHP Code:
//#CLIENTSIDE
// other code..
function onTimeOut() {
if (players.size() > 0) // Useless on client-side since script won't run
setTimer(0.1); // if player is in another level.
else
setTimer(0);
// Loops through all npcs near the switch
for (temp.i : findareanpcs(this.x-2, this.y-2, 2, 2)) {
// Checks if npc is a bomb
if (temp.i.isinclass("bomb")) { // Added the { for clarity
// Triggers switch
SwitchDB.door.(@this.switchid).trigger("DoorOpened", null);
}
// Sleeps for 3.2 seconds
sleep(3.2);
// Recursively calls onTimeout again, leading to an infinite loop.
// Without a sleep the script would break quite quickly after hitting
// the stack/maxloop limit.
onTimeOut();
}
}
Notice how you're sleeping for every NPC around the switch and then calling onTimeout which causes that nasty loop.
Also something about calling onTimeout directly like that is just unsettling to me, the only time I do that is when I'm hacking around with code.
Recursion crash example:
PHP Code:
//#CLIENTSIDE
function onCreated() {
recurse(0);
}
function recurse(a) {
echo(a);
recurse(a+1);
}
That's as big as hint as I'll give you, I'm sure you can figure out what you need to change.