Skip to content

Exports and Events ​

Use these when your server's death or ambulance script should decide when the spirit appears, or when another resource needs to read or change the effect.

Server exports ​

ExportReturnsDescription
Trigger(source)booleanA player died: plays the spirit for them. false when it was skipped (effect off, cooldown, CanTrigger)
GetSettings()tableThe current menu settings (spirit, poses, particles, sound, active, version)
SetActive(mode){ ok, error? }'on', 'off' or 'auto', saved like /spiritadmin <mode>
lua
-- server side, when your script decides the player is dead
exports.leno_spirit_pro:Trigger(source)

-- turn the effect off during an event, and back to the config afterwards
exports.leno_spirit_pro:SetActive('off')
exports.leno_spirit_pro:SetActive('auto')

Client export ​

ExportReturnsDescription
Trigger()—Reports the local player's death, as if they had just died
lua
-- in your death script, client side, at the moment the player dies
exports.leno_spirit_pro:Trigger()

The same thing as a local client event:

lua
TriggerEvent('leno_spirit_pro:trigger')

It is a local event (AddEventHandler), so other clients and the server can't trigger it.

What still applies ​

A manual trigger goes through the same checks as a detected death:

  • General.cooldownSeconds;
  • the On / Off state (General.enabled, General.activePeriod, /spiritadmin);
  • SpiritHooks.CanTrigger (not with visibility = 'local', see Configuration);
  • General.visibility: with 'nearby', players near the dead player see the spirit too;
  • players who hid the effect with /spirit don't see it.

WARNING

If you trigger the effect yourself, set General.triggerMode = 'manual'. Otherwise the built-in detection also fires. On last-stand scripts that can play a second spirit: one when the player goes down, and one when your script triggers it.

Server hooks ​

server/main.lua is open. Override these functions to change who is staff and when a spirit plays.

HookReturnCalled when
SpiritHooks.IsStaff(source)booleanOpening the menu, saving, resetting, /spiritadmin, /spirittest. source 0 is the console. Default: the ACE in Config.Permissions.admin
SpiritHooks.CanTrigger(source)booleanBefore a death shows a spirit. Return false to skip it
SpiritHooks.OnSettingsSaved(source, settings, changedSections)—After a save, also when config.lua couldn't be written. changedSections is a list such as { 'spirit', 'poses' }
lua
-- server/main.lua: no spirit for players in jail
function SpiritHooks.CanTrigger(source)
    return not Player(source).state.inJail
end

Client hooks ​

client/main.lua is open too.

HookReturnCalled when
SpiritClientHooks.BeforeOpenMenu()booleanBefore the menu opens. Return false to stop it
SpiritClientHooks.CanShowSpirit(serverId)booleanBefore this client draws the spirit of player serverId. Return false to hide it
SpiritClientHooks.OnSpiritStart(serverId)—This client starts drawing the spirit
SpiritClientHooks.OnSpiritEnd(serverId)—This client finished drawing the spirit

INFO

The hook files are loaded before the rest of the resource. Only override the functions there; don't register events, commands or threads in them.

Bridges ​

bridge/ holds the notification and death-detection code per framework (bridge/notify/*, bridge/death/*). Edit these to support another system.

Security ​

Every staff request from the menu is checked again on the server, whatever the menu sent: the permission (IsStaff), a 500 ms rate limit, and full validation of the settings against shared/schema.json.