Did something like this on the Testbed server back in 2009. This was due the to the fact scripters loved to upload staff tools and write their name with thousands of staff blocks. Best part? putnpcs with non-existing classes
PHP Code:
/*
Used to clear classes from levels.
By classes I mean staffsigns, staffblocks etc.
just edit 'temp.class' to what class to search for..
Also remove the 'return;' to enable
(Comment it out for fast toggling)
-Chompy
*/
/*
2.feb.09
Most used classes:
1. shared_blocks: 552 times
-- After cleaning --
Found 546x (shared_blocks) in new1.nw
------------------------------ 1th may
Found 186x (shared_blocks) in firstscript1.nw
Found 2x (shared_blocks) in jail_outside.nw
Found 520x (shared_blocks) in era_sewerph-house14-1.nw
Found 1x (shared_blocks) in ce_shop1.nw
Found 1x (shared_blocks) in ******.nw
Found 1x (shared_blocks) in ******.nw
*/
function onCreated() {
temp.paths = findfiles("*.nw", 1);
temp.class = "shared_blocks";
return;
for(temp.path : paths) {
temp.pos = path.tokenize("/");
temp.lvl = pos[pos.size()-1];
temp.lvl2 = findlevel(lvl);
temp.blocks = 0;
for(temp.n : lvl2.npcs) {
if (class in n.joinedclasses) {
blocks ++;
n.destroy();
}
}
if (blocks > 0) {
echo("Found "@ blocks @"x ("@class@") in "@ lvl2.name);
}
}
}
Simply you would do /stats in RC chat, then look for the classes that occured to the most, and put that class name in the script, and it would look through levels for that class and destroy it.
Very old script, never optimized it or anything, but it takes a little different approach than yours.
I think you only need r to the folders the levels are in if I'm not mistaken, can't remember. Found this in an old testbed server backup
NB! Yes, you have no idea how often I saw era weapons, levels and whatever era stuff on the testbed stuff. was so fun deleting it. Most popular server's stuff to mess around in 2009 on testbed.