Find the right Rust hook
Describe what should trigger your code. Get the Oxide and Carbon hooks that fire for it, with working examples.
How the hook finder works
Oxide and Carbon plugins react to the game through hooks: methods with a fixed name, like OnEntityDeath or CanLootEntity, that the framework calls when something happens on the server. The hard part is knowing which name to look for.
Type what you want to react to in your own words. The finder matches it against every hook name, what the hook does and what it is usually used for, including common synonyms (a player "dies" finds death hooks, "opens a crate" finds loot hooks).
On hooks and Can hooks
- On hooks (
OnPlayerConnected,OnEntityDeath) tell you something happened. Use them to react: give a reward, log, send a message. - Can hooks (
CanBuild,CanLootEntity) ask permission first. Return a non-null value to block the action, returnnullto let the game decide.
Each result links to a page with the signature, the parameters, what returning a value does, and a complete plugin that uses the hook.
FAQ
What is a hook in a Rust plugin?
A hook is a method the Oxide or Carbon framework calls when something happens in the game, such as a player connecting or an entity taking damage. You add a method with the same name and parameters to your plugin class and it runs automatically.
Are Oxide hooks the same in Carbon?
Yes, for almost all hooks. Carbon loads Oxide plugins and calls the same hooks with the same parameters. Each hook page notes when a hook is known to behave differently.
How do I stop an action with a hook?
Use the matching Can or On hook that has an object return type and return a non-null value, for example return false;. Returning null lets the game continue normally.