🪝 Hooks System
Hooks let another resource run code right before NoLag Properties does something, like selling a property or letting a player into a shell. Your hook gets a table with the details. Return false to stop the action.
Hooks run on the server only. Register them from a server script in your own resource.
Register a hook
- hookName:
stringOne of the hook names listed below - callback:
functionGets the payload table for that hook - Returns
numberThe hook id. Keep it if you want to remove the hook later.
Cancel an action
Only false cancels. Returning true, nil, or nothing lets the action continue.
When several hooks are registered for the same name, they run in the order they were registered. The first one that returns false stops the action, and the hooks after it do not run.
Remove a hook
- hookId:
numberThe id returned byregisterHook. If you leave it out, every hook your resource registered is removed.
Hooks are also removed by themselves when the resource that registered them stops.
Keep hooks fast
Hooks run while the player waits for the action. A hook that takes 100 ms or more prints a warning in the server console with the resource and hook name. Avoid slow database queries or HTTP calls inside a hook.
Hook list
The player field
Most payloads include player. This is the NoLag Properties framework player object, the same on every framework. Useful fields:
player.source:numberServer idplayer.identifier:stringCharacter identifierplayer.job.name:stringJob nameplayer.getName():stringCharacter name