Dump Useless Local NPCs
I made this script in 2011-2012 and it worked a bit differently (some stuff was changed it seems). Basically the idea is to delete any putnpc2's that exist on the server, in levels that no longer exist.
The first time running the script on UN (2011-2012) reduced their local NPCs from ~4950 to ~690. Running it on UN earlier today reduced their local NPCs from ~6k to ~4k. Running it on Era about an hour ago reduced their local NPCs from > 10k (loadFolder only goes up to 10k entries) to ~3k after 2 presses (first press: ~6k. second press: ~3k). I've had good experiences with it reducing NPC server startup times as well as NC load times (for servers with slow NCs). It's part of a bigger NPC. I just snipped this part since it seems the most universal. PHP Code:
Basically, since sometime in 2012 you can no longer deleteFile() anything in npcs/ (even with npc server rw and protectdbnpcs=false in server ops (I tested, jic)), but you can still moveFile() them to another folder and delete them there. It's an unfortunate nuisance, but so it is. It outputs how many local NPCs were deleted in an echo(), so let me know if your results are interesting. |
vouch
best thing under atrius |
Hey Nas <3
Pretty cool- I suppose it only helps on server load up. A plan for the future is to delete the levels if they are not being used and re-create the level when needed and keep the putnpcs (for houses / gang houses etc) |
Quote:
This script addresses only the putnpc2's that aren't this.savelocally that exist inside of levels that are now deleted. You could expand the script (simply make it recursive) to check the this.savelocally ones, but I saw no need (as they are not in the server's memory anyway). I suppose that could help with file browser opening speed, though (or you can just not give yourself rw to that part of the file browser in the first place! ie "-rw npcs/*/*"). The putnpc2's that don't save locally load up when the NPC server is loaded and are loaded into your NC when you load into the server, so they do create lag in NC loadtimes and NPC server restarting. Additionally, I suspect that a lot of the putnpc2's that exist in defunct levels could likely be the result of corrupt ex-staff who added them to do possibly malicious things (Delete levels, add gralats, whatever). As an aside, if you wanted to get "serious" with putnpc removal, you may couple this script with another script (or slightly modify it) to detect which levels have the most NPCs, via the same methodology. Here is a (hack-ish) quick version I made with the script I posted above: PHP Code:
When I ran it on UN (we had 4k putnpc2's left yesterday when I ran the first script), it got 1.1k hits in 1 level from an old quest. We dumped that level and ran it again and got about 800 NPCs from a spar tourney viewer (the tourney viewers weren't destroying on the serverside properly). We fixed the glitch and dumped that level. We did that for about 5 things. Then we saw the bulk of the putnpc's left (I checked npcs/ myself for them, which was now loadable!) were of the classes: gralats, gralats_death, newhatdrop, and epdrop. Those are items players can drop and give to other players. So I simply added an onInitialized() destroy(); clause on them, and rebooted the NPC server; let's be real, that kind of stuff shouldn't be expected to persist a server restart anyway. In the rare event that we reboot the npc server while a player was dropping a hat, we have logging for that anyway. The remaining NPCs were from the playerhouse system, so we added this.savelocally to those NPCs. All-in-all, we only had about 60 putnpc's left after all of that. I went through them all personally (took about 10-15 min) and they were old BS classes that just forgot to destroy (or just had no script in them), so I just deleted them manually. In total, the whole project took about 1-1.5 hours, but lowered UN's putnpc2 count from ~6k to 0. But I figure if you just want a quick-fix to remove a bunch of putnpc2's that nobody is using anymore, that script up top is a one-press solution to at least a few thousand! |
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:
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. |
Quote:
I cannot decrease my amount and re-run the script, however. Do you have any recommendations for checking entries > 10,000 ? |
All times are GMT +2. The time now is 05:11 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.