Skip to content

Hooks ​

← BLN Society overview

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 returnResult
nothing / nilOperation proceeds
falseBlocked β€” caller gets blocked_by_hook
stringBlocked β€” caller gets that code (must exist in locale)

Hook list ​

data always includes actor ({ charId, source, system }).

Hookdata fields besides actor
beforeMemberAddsocietyId, characterId, rankId
beforeMemberRemovesocietyId, characterId
beforeRankChangesocietyId, characterId, rankId, previousRankId
beforeDutyChangesocietyId, characterId, onDuty
beforeDepositsocietyId, amount, currency
beforeWithdrawsocietyId, amount, currency
beforeTransfersocietyId, targetSocietyId, amount, currency
beforePayrollsocietyId
beforePaycheckCollectsocietyId, characterId
beforeStorageBuysocietyId, key, label, slots, maxWeight, acceptWeapons, minRankLevel, cost
beforeSocietyDeletesocietyId

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.*.