Developer
Overview
Integration happens through the open/ folder. There are no exports. Each handler is a plain function with a default body; override it to extend or block a flow without touching the core. The handlers run on the side their file targets: open/server.lua on the server, open/client.lua on the client, open/shared.lua on both.
Server Handlers
Located in open/server.lua.
BeforeGiveItem
1function OpenServer.BeforeGiveItem(src, item, amount)
2 return true
3endFires before a trap is refunded to the player on pickup. Return false to block the give.
BeforePlace
1function OpenServer.BeforePlace(src, trapTypeName, coords)
2 return true
3endFires after the core placement checks pass, before the trap is created. Return false to block placement.
BeforeCapture
1function OpenServer.BeforeCapture(trap, targetModelHash, targetCitizenId)
2 return true
3endFires before a capture is finalized. targetModelHash is set for animal captures, targetCitizenId for player captures. Return false to reject the capture.
OnActionComplete
1function OpenServer.OnActionComplete(src, actionType, trap)
2endFires after any state change. actionType is one of 'place', 'bait', 'capture', 'kill', 'open', 'close', 'pickup', 'expire', 'break'. src is nil for system events such as bait expiry.
'capture' and 'kill' are reported by the client and are not proof an animal was present. If rewards are granted here, credit trap.ownerCitizenId rather than src, and add server-side checks of your own.
OnCleanupDelete
1function OpenServer.OnCleanupDelete(trapId, trapRecord)
2endFires when the cleanup scheduler removes an inactive persistent trap. trapRecord may be nil if the trap was already gone from memory.
Client Handlers
Located in open/client.lua.
Notify
1function OpenClient.Notify(message, type)
2 Bridge.Notify(message, type)
3endRoutes every notification. Override it to send notifications through a custom UI. type is 'info', 'success', 'warning' or 'error'.
CanPlace
1function OpenClient.CanPlace(trapTypeName)
2 return true
3endFires before placement starts. Return false to cancel based on a custom condition such as a zone or job check.
BeforeOpenMenu
1function OpenClient.BeforeOpenMenu(trapData)
2 return true
3endFires before the interaction panel opens. Return false to block it.
AfterPlace / AfterCapture / AfterOpen / AfterKill
1function OpenClient.AfterPlace(trapData) end
2function OpenClient.AfterCapture(trapData) end
3function OpenClient.AfterOpen(trapData) end
4function OpenClient.AfterKill(trapData) endEach fires after the matching action resolves on the client, with the trap data. Use them to drive custom effects.
Shared Handlers
Located in open/shared.lua.
OnPlayerAction
1function OpenHandlers.OnPlayerAction(src, data)
2 return true
3endA generic guard the core calls on a player-initiated action. Return false to refuse. Use it for a server-wide block, for example during an event.
ValidateAction
1function OpenHandlers.ValidateAction(src, actionType)
2 return true
3endPer-action validation called just before the action runs. actionType is 'place', 'bait', 'capture', 'kill', 'open', 'close', 'pickup' or 'repair'. Return false to silently refuse.
Examples
1function OpenClient.CanPlace(trapTypeName)
2 if InSafeZone(cache.ped) then
3 OpenClient.Notify('You cannot place traps here.', 'error')
4 return false
5 end
6 return true
7end1function OpenServer.OnActionComplete(src, actionType, trap)
2 if actionType ~= 'kill' then return end
3 local ownerSrc = GetSourceFromCitizenId(trap.ownerCitizenId)
4 if ownerSrc then
5 Bridge.GiveItem(ownerSrc, 'raw_meat', 1)
6 end
7end1function OpenHandlers.OnPlayerAction(src, data)
2 return not EventActive
3end