Static Entities lets staff make entities persistent, so that they are saved with the map and spawned again when it loads. Entities are made static or unstatic with the static add and static remove commands or with the Static Add/Remove tool, which all go through the PlayerMakeStatic hook. Only whitelisted classes can be made static: props, ragdolls, lights and lamps by default, and whatever plugins add with StaticEnts:whitelist_ent. The plugin turns Sandbox's own persistence off and saves and loads through the PersistenceSave and PersistenceLoad hooks instead. The fl_persistence_backup console command writes a copy of all persistent entities to the data folder.

Summary

Hooks

Runs the PersistenceLoad hook once the map's entities have been created.
Loads the saved static entities of every whitelisted class.
Saves every persistent entity to the plugin data of the current schema and map, one 'static/<class>' entry per entity class.
Makes the entity the player is looking at static, or removes its static status, and notifies the player about the outcome.
Registers the 'static_tool' permission.
Runs the PersistenceSave hook whenever the framework saves its data.
Runs the PersistenceSave hook when the server shuts down.

Methods

Spawns the saved static entities of one class and marks them as persistent.
Allows entities of a class to be made static and to be loaded from the saves.

Hooks

StaticEnts:InitPostEntity()

server plugins/staticents/plugin/sv_hooks.lua:21

Runs the PersistenceLoad hook once the map's entities have been created.

StaticEnts:PersistenceLoad()

server plugins/staticents/plugin/sv_hooks.lua:76

Implements hook PersistenceLoad

Loads the saved static entities of every whitelisted class.

StaticEnts:PersistenceSave()

server plugins/staticents/plugin/sv_hooks.lua:40

Implements hook PersistenceSave

Saves every persistent entity to the plugin data of the current schema and map, one 'static/<class>' entry per entity class. Runs the PrePersistenceSave hook first and the PostPersistenceSave hook once everything has been saved.

StaticEnts:PlayerMakeStatic(actor, is_static)

server plugins/staticents/plugin/sv_hooks.lua:87

Implements hook PlayerMakeStatic

Makes the entity the player is looking at static, or removes its static status, and notifies the player about the outcome. The entity's class has to be whitelisted and the player needs the 'static' permission.

Parameters

  • actor Player
  • is_static Boolean true to make the entity static, false to make it unstatic

StaticEnts:RegisterPermissions()

shared plugins/staticents/plugin/sh_plugin.lua:16

Implements hook RegisterPermissions

Registers the 'static_tool' permission.

StaticEnts:SaveData()

server plugins/staticents/plugin/sv_hooks.lua:122

Implements hook SaveData

Runs the PersistenceSave hook whenever the framework saves its data.

StaticEnts:ShutDown()

server plugins/staticents/plugin/sv_hooks.lua:29

Runs the PersistenceSave hook when the server shuts down.

Methods

StaticEnts:load_class(ent_class)

server plugins/staticents/plugin/sv_hooks.lua:129

Spawns the saved static entities of one class and marks them as persistent. Does nothing if there is no usable save for that class. Serverside only.

Parameters

  • ent_class String entity class, e.g. 'prop_physics'

StaticEnts:whitelist_ent(ent_class)

server plugins/staticents/plugin/sv_hooks.lua:154

Allows entities of a class to be made static and to be loaded from the saves. Serverside only.

Parameters

  • ent_class String entity class

Defined in