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
| Export | Returns | Description |
|---|---|---|
Trigger(source) | boolean | A player died: plays the spirit for them. false when it was skipped (effect off, cooldown, CanTrigger) |
GetSettings() | table | The 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
| Export | Returns | Description |
|---|---|---|
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 withvisibility = 'local', see Configuration);General.visibility: with'nearby', players near the dead player see the spirit too;- players who hid the effect with
/spiritdon'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.
| Hook | Return | Called when |
|---|---|---|
SpiritHooks.IsStaff(source) | boolean | Opening the menu, saving, resetting, /spiritadmin, /spirittest. source 0 is the console. Default: the ACE in Config.Permissions.admin |
SpiritHooks.CanTrigger(source) | boolean | Before 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
endClient hooks
client/main.lua is open too.
| Hook | Return | Called when |
|---|---|---|
SpiritClientHooks.BeforeOpenMenu() | boolean | Before the menu opens. Return false to stop it |
SpiritClientHooks.CanShowSpirit(serverId) | boolean | Before 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.
