Server-side hooks of the Static Entities plugin that make entities static and save and restore them across restarts.
The file removes Sandbox's own persistence hooks and takes their place: PlayerMakeStatic marks a whitelisted
entity (props, ragdolls, edit_ and gmod_ entities) persistent for an admin, PersistenceSave copies every
persistent entity into the static schema data with the duplicator on shutdown and after a change, and
PersistenceLoad pastes them back once the map has loaded.
Backported from the Flux project.
Summary
Hooks
PersistenceLoad hook.PersistenceSave hook to save static entities.Hooks
Called after the map has loaded all of its entities; runs the PersistenceLoad hook.
Implements hook PersistenceLoad
Called to load persistent entities; pastes the saved static entities back and marks them persistent.
Custom fields saved with each entity are merged back into its table, and the items of a saved cwInventory
are created again as item instances.
Implements hook PersistenceSave
Called to save persistent entities; copies every static entity with the duplicator into the schema data.
cwStaticEnts:PlayerMakeStatic(player, bIsStatic)
server gamemodes/catwork/plugins/staticents/plugin/sv_hooks.lua:32Implements hook PlayerMakeStatic
Called to make the entity a player is looking at static (persistent) or not.
Run by the Static and UnStatic commands and the static tool. Only admins may use it, and only on
props, ragdolls and edit_/gmod_ entities; the player is notified of the result or of why it
failed.
Parameters
- player Player The player making the change
- bIsStatic Boolean True to make the entity static, false to make it normal again
Implements hook SaveData
Called when Catwork saves its data; saves the static entities if any were added or removed since the last save.
Keeps a crash from losing which entities are static. Nothing is saved before the saved entities have been loaded, so that a failed load is not saved over.
Called when the server shuts down; runs the PersistenceSave hook to save static entities.