Shutdown Module¶
This page documents the shutdown system in cv_framework. It provides a single server event you can listen to when the framework is about to shut down, so modules can save state (characters, vehicles, etc).
What it does¶
- Provides a server-side API to trigger a shutdown signal.
- Emits a framework-wide event that other resources can listen to.
- Uses a single payload format so listeners can rely on consistent data.
- Fires on resource stop to catch restarts/stops of cv_framework.
Event¶
Event name¶
cv_framework:server:Shutdown
Payload¶
The event receives a table with the following fields:
source(string): Who triggered the shutdown. Examples:resource,manual.reason(string or nil): Optional reason, likeresource_stop.secondsRemaining(number): Remaining seconds until shutdown; default 0.startedAt(number): Unix timestamp when the shutdown trigger was fired.
Example payload:
Server API¶
Trigger shutdown event¶
Notes:
- This will only trigger once per resource lifecycle.
- The startedAt field is added automatically.
Check if shutdown already triggered¶
Example usage in a module¶
AddEventHandler('cv_framework:server:Shutdown', function(payload)
local player = CVPlayer.GetPlayer(source)
if not player or not player.charId then
return
end
-- Save module-specific data here
end)
Current built-in listeners¶
The framework already listens to this event to save: - Character data in the player module - Persistent vehicles in the vehicles module
You can add your own listeners in any resource.
Related behavior¶
- On
onResourceStopof cv_framework, the shutdown trigger is fired automatically. - There is no txAdmin integration in this system.