This may be too general but I'm a newbie to game development and maybe in general with Rust being the first game I've written code for but I've been writing / fixing up plugins learning like crazy and now I need to know how hooks work. Recently I came across a plugin that creates custom objects with built in hooks like OnPlayerInteractWithCustomObject and it got me thinking, why does this work? If anyone could give me a basic overview of why the hooks work, even the oxide ones such as OnPlayerInit(). I get that events trigger them but how does it all link up, is it a naming scheme or something else? Thanks in advance.
Solved How do hooks work?
Discussion in 'Rust Development' started by Pois0n, Jun 11, 2018.
-
Wulf Community Admin
That would just be a method, not really a hook. A hook is something in Oxide or a plugin that something outside of it calls. Generally though, a hook would mainly be what Oxide injects or provides for plugins.
How a hook works in Oxide:
- Hook is injected into game at a certain area
- When that area is called in the game, the hook is hit
- Oxide then calls all plugins that implement that hook
-
Ok, I think I follow.
How does the method get called then? Even the oxide ones such as OnServerInitialized(), what is the relation between oxide and that method since there is no hard code reference to oxide when you define the method in your plugin why do they get connected.
For example the code I'm looking at is for zones. A zone is a defined object with a radius and starting position x, y, z. Internally defined methods on the object such as OnPlayerEnterZone exist and get called, I'm just trying to figure out how that is possible. -
Wulf Community Admin