We have added a new option for optimized storage of npcs (putnpcs2).
By default those npcs are all stored in the same folder and loaded at startup. The problem is that some servers started to use huge amounts of those npcs or storing tons of data in them. That makes the startup take a lot of time, and the server takes a lot of memory.
But many of those npcs don't need to be loaded at startup and don't need to sit in the memory all the time. They are like local npcs, but want to store additional data.
For that there is now a new option:
Server-options: newnpcstorage=true
NPC-variable: this.savelocally = true;
If the new npc storage is enabled, and you set the flag savelocally = true, then the npc is saved into a subfolder (uses the level name as folder name) and is only loaded when that level is loaded (when a player enters the room).
On N-Pulse that reduced the memory from 300 MByte to 35 Mbyte, on Unholy Nation from 400 MByte to 110 MByte, so it should be less laggy now.
Important things to keep care of:
- by default npcs don't use that storage system, you need to set savelocally = true, e.g. like that:
Graal Script Code:
function onCreated() {
this.savelocally = true;
}
If you want to use this for already existing npcs, then add this to the class:
Graal Script Code:
function onInitialized() {
this.savelocally = true;
}
- this is currently only used for npcs in single levels, not for npcs on gmaps
- to actually benefit of the lower memory usage you eventually need to restart the npcserver again, you will see a lower number of dbnpcs in /stats then.
- if you set savelocally = true; then the npc is not loaded before a player enters the level, and the npc is also removed from memory when there is no player for a few minutes, so don't use it for npcs which you want to access from everywhere and where you want to have the script running forever
- if you want to see the npcs in the filebrowser then add "r npcs/*/*" to your rights
- this thing will also be used by the future online level editor to store npcs
- it is currently only enabled for Unholy Nation and N-Pulse, but will also be available for the other servers soon (or on request)