Server-side hooks of the Spawn Saver plugin that save a character's position when it unloads and restore it on the next spawn.

The position, eye angles and map are kept in the SpawnPoint character data, written on character unload and before a map change, and used once on the same map. Other plugins can veto both with the ShouldSavePlayerSpawn hook.

Summary

Hooks

Called before the map changes; saves every player's position as if their character unloaded.
Called when a player's character unloads; saves where they were standing to the SpawnPoint character data.
Called after a player spawns; moves them back to their saved position on the same map and clears it.

Hooks

cwSpawnSaver:OnMapChange(newMap)

server gamemodes/catwork/plugins/spawnsaver/plugin/sv_hooks.lua:32

Implements hook OnMapChange

Called before the map changes; saves every player's position as if their character unloaded.

Parameters

  • newMap String The map being changed to

cwSpawnSaver:PlayerCharacterUnloaded(player)

server gamemodes/catwork/plugins/spawnsaver/plugin/sv_hooks.lua:13

Implements hook PlayerCharacterUnloaded

Called when a player's character unloads; saves where they were standing to the SpawnPoint character data.

Only saves living players while the spawn_where_left config is on and the ShouldSavePlayerSpawn hook does not return false.

Parameters

  • player Player The player whose character unloaded

cwSpawnSaver:PostPlayerSpawn(player, bLightSpawn, bChangeClass, bFirstSpawn)

server gamemodes/catwork/plugins/spawnsaver/plugin/sv_hooks.lua:46

Implements hook PostPlayerSpawn

Called after a player spawns; moves them back to their saved position on the same map and clears it.

Light spawns are ignored, as are players for whom the ShouldSavePlayerSpawn hook returns false.

Parameters

  • player Player The player who spawned
  • bLightSpawn Boolean Whether this is a light spawn that keeps the player's state
  • bChangeClass Boolean Whether the spawn comes from a class change
  • bFirstSpawn Boolean Whether this is the character's first spawn

Defined in