Hook is a way for modding frameworks to call your mod's code every time a certain action happens.
Some Hooks Are:
- If an Entity takes damage
- After a Player picks up an item
- If a locked door can be opened
- After a player pushes a boat
- After a player wakes up
- Before a player respawns
Some hooks control if an action should happen, some trigger after an action happens and some will do both.
A modding framework such as Oxide will insert their special
CallHook functions throughout the Rust Server code.
CallHook function will run any code in your plugin that:
- Matches the name of the hook
- Has the same parameters as the hook
Go to the Oxide Documentation page to see a list of every single hook.
For this example we are going to prevent players from damaging boats.
We chose the hook
OnEntityTakeDamage as it occurs when damage is dealt but we can block it!
First we copy the hook found in the documentation into our plugin.
Now all we need to do is remove the default code and put in our code.