Spawn Saver puts a character back where it was when its player left. Whenever a character is saved, the position and the eye angles of its player are written into the generic data of the character together with the name of the map. When the character is loaded again on the same map, its player is moved to that spot right after they have spawned. If something stands in the way they are moved to the nearest free spot; if the spot is outside of the world, or nothing around it is free, they stay at the regular spawn point.

A player in observer mode, in noclip or lying ragdolled is not where their character would be expected, so nothing is written for them and the spot of the last save stays. A character whose player is dead forgets its spot and starts at a regular spawn point next time. Plugins change these rules with the ShouldSavePlayerSpawn and ShouldRestorePlayerSpawn hooks.

The 'spawn_where_left' config turns all of this on and off. While it is off, characters forget their spots as they are saved.

The spot is kept in the character data under the 'spawn_point' key, as a table with the fields map, position and angles; SpawnSaver:get_spawn_point returns it.

Summary

Hooks

Moves the player to the spot saved with the character they have loaded, and lets the position of the player be saved with that character from now on.
Writes the place where the player stands into their active character before it is saved.
Leaves the player at the regular spawn point while they are dead, ragdolled, in observer mode or in noclip.
Keeps the spot that was saved before while the player is ragdolled, in observer mode or in noclip.

Methods

Returns the spot saved with a character, if it was saved on the map that is running now.
Moves a player to the spot saved with a character.
Writes the place where a player stands into the data of a character, unless a ShouldSavePlayerSpawn hook is against it.

Hooks

SpawnSaver:PostCharacterLoaded(owner, character)

server plugins/spawnsaver/plugin/sv_hooks.lua:47

Implements hook PostCharacterLoaded

Moves the player to the spot saved with the character they have loaded, and lets the position of the player be saved with that character from now on.

Parameters

  • owner Player
  • character Character the loaded character

SpawnSaver:SaveCharacterData(owner, character)

server plugins/spawnsaver/plugin/sv_hooks.lua:28

Implements hook SaveCharacterData

Writes the place where the player stands into their active character before it is saved. A dead player makes the character forget its spot, and so does turning the 'spawn_where_left' config off: a spot that was saved before is cleared once, and nothing is written as long as there is none. Banned characters, whose players stay dead, and characters that are being loaded and have not been given their spot yet are left alone.

Parameters

  • owner Player
  • character Character the character that is being saved

SpawnSaver:ShouldRestorePlayerSpawn(target, _character, _spawn_point)

server plugins/spawnsaver/plugin/sv_hooks.lua:72

Implements hook ShouldRestorePlayerSpawn

Leaves the player at the regular spawn point while they are dead, ragdolled, in observer mode or in noclip.

Parameters

  • target Player
  • _character Character the loaded character
  • _spawn_point Map the saved spot: map, position and angles

Returns

  • Boolean false when the player should not be moved, otherwise nil

SpawnSaver:ShouldSavePlayerSpawn(target, _character)

server plugins/spawnsaver/plugin/sv_hooks.lua:60

Implements hook ShouldSavePlayerSpawn

Keeps the spot that was saved before while the player is ragdolled, in observer mode or in noclip.

Parameters

  • target Player
  • _character Character the character that is being saved

Returns

  • Boolean false when the position of the player should not be saved, otherwise nil

Methods

SpawnSaver:get_spawn_point(character)

server plugins/spawnsaver/plugin/sv_plugin.lua:10

Returns the spot saved with a character, if it was saved on the map that is running now.

Parameters

  • character Character

Returns

  • Map the spot: map [String], position [Vector] and angles [Angle]; nil when the character has none or it belongs to another map

SpawnSaver:restore_spawn_point(target, character)

server plugins/spawnsaver/plugin/sv_plugin.lua:50

Moves a player to the spot saved with a character. Nothing happens when the character has no spot for the current map, when the spot is outside of the world or when a ShouldRestorePlayerSpawn hook is against it. A player who would be stuck there is moved to the nearest free spot, and put back where they were when there is none.

Parameters

  • target Player
  • character Character the character whose spot is used

Returns

  • Boolean true when the player was moved

SpawnSaver:save_spawn_point(target, character)

server plugins/spawnsaver/plugin/sv_plugin.lua:24

Writes the place where a player stands into the data of a character, unless a ShouldSavePlayerSpawn hook is against it. The spot reaches the database the next time the character is saved.

Parameters

  • target Player the player whose position and eye angles are taken
  • character Character the character to keep them with

Returns

  • Boolean true when the spot was written

Defined in