Where to find hooks like OnFriendAttackedSolved

I've been looking through some code in some plugins to get my head around creating my own plugin and I've seen the FriendlyFire plugin has a line like this:

Interface.Oxide.CallHook("OnFriendAttacked", attacker, victim, info);​
I'm struggling to find where that "OnFriendAttacked" hook can be found. I've looked at the Rust and Universal API documentation and "OnFriendAttacked" doesn't appear anywhere and I've used JustDecompile on a bunch of the .dlls in the RustDedicated_Data\Managed folder and can't see anything that relates.

Could someone point me in the right direction? If I can find where those hooks can be found, it'll make much more sense to me!

That hook is provided by the plugin itself, not Oxide. It's physicalled called with that line you mentioned and calls that method in any plugin that has that method.

asR8CdO31Zk92qb.jpg Wulf

That hook is provided by the plugin itself, not Oxide. It's physicalled called with that line you mentioned and calls that method in any plugin that has that method.

Thanks for the response. So does that mean that I don't even need to have the plugin installed or even reference any plugin name, and it will somehow look at all plugins and look for that method in them? Does it look at a uMod database for that or something? 🤔 I just ran that code in my own plugin and it works as expected, but I'm not referencing any other plugins.

The plugin that calls that hook would have to be installed, it is the provider of that hook. Any plugin can call any hook like that.

Sorry to sound dumb; I'm sure it's a basic concept I just need to click...
I'm running a server on my local machine, the only file inside the oxide\plugins directory is the .cs file for the Clans plugin right now. There's no [PluginReference] section or anything, but I can see:

        private void ClanChat(IPlayer player, string message)
        {
            if (player == null)
                return;

            Clan clan = storedData.FindClanByID(player.Id);
            if (clan == null)
                return;

            string str = string.Format(Message("Chat.Alliance.Format"), clan.Tag, clan.GetRoleColor(player.Id), player.Name, message);

            clan.Broadcast(string.Format(Message("Chat.Clan.Prefix"), str));

            Interface.CallHook("OnClanChat", player, message, clan.Tag);
        }​
There aren't any other plugins in that folder and there's no method in the plugin called "OnClanChat", so I don't get how it works if there aren't any other plugins installed or referenced for that to work.

When a plugin uses something like...

Interface.CallHook("OnClanChat", player, message, clan.Tag);​

It is calling out to any plugins that have a method with the appropriate signature that that hook uses. If plugins do not have that hook, nothing happens.

OK, that makes sense, thanks. Where does it look up the available plugins, do you know? As I don't have any other plugins installed, but it's clearly calling a hook from another plugin, I'm guessing it's looking online at the uMod/Oxide database of plugins?

Locked automatically