Hooks β
Hooks run before an operation commits. Return a value to veto; return nothing to allow.
To react after something already happened, use Events instead.
Register with RegisterHook from the API:
lua
exports.bln_society:RegisterHook('beforeWithdraw', function(data)
if data.amount > 500 and not IsBankOpen() then
return 'bank_closed' -- custom error code
end
-- return false for generic blocked_by_hook
-- return nothing to allow
end)Handlers are removed automatically when your resource stops.
Return values β
| You return | Result |
|---|---|
nothing / nil | Operation proceeds |
false | Blocked β caller gets blocked_by_hook |
| string | Blocked β caller gets that code (must exist in locale) |
Hook list β
data always includes actor ({ charId, source, system }).
| Hook | data fields besides actor |
|---|---|
beforeMemberAdd | societyId, characterId, rankId |
beforeMemberRemove | societyId, characterId |
beforeRankChange | societyId, characterId, rankId, previousRankId |
beforeDutyChange | societyId, characterId, onDuty |
beforeDeposit | societyId, amount, currency |
beforeWithdraw | societyId, amount, currency |
beforeTransfer | societyId, targetSocietyId, amount, currency |
beforePayroll | societyId |
beforePaycheckCollect | societyId, characterId |
beforeStorageBuy | societyId, key, label, slots, maxWeight, acceptWeapons, minRankLevel, cost |
beforeSocietyDelete | societyId |
Example β block hires outside business hours β
lua
exports.bln_society:RegisterHook('beforeMemberAdd', function(data)
if data.societyId ~= mySocietyId then return end
if not IsBusinessOpen() then
return 'business_closed'
end
end)Hook names are also available on GetConstants() as Const.HOOK.*.
