Trigger plugin from specific switch entity

Quick question - how would I trigger something in an Oxide plugin from a specific switch built into a custom map?

For example if I wanted to broadcast a message in chat when someone hits a specific red button built into the map.

Thanks in advance.

Thanks Razor, I was afraid that was the case - I was actually hoping that there would be some way I could do this that didn't depend on the button being at a specific location each wipe...

If the button is at a consistent relative position, such as relative to a monument, then the logic could go something like this.

  1. Determine whether it's a Monument button/switch, which it probably is if it has OwnerID 0 and is not parented to another object.
  2. Get the nearest monument, by comparing the distance to each monument in TerrainMeta.Path.Monuments. If the closest distance exceeds a value you configure, then assume the button is not at a monument.
  3. If the button is at a monument, compute the position relative to the monument, and verify that the relative position is what you expect, or within a particular tolerance.
  4. If the button matches, do something special.
As for optimization, you can build a cache of such buttons when the plugin loads, then you can simply check the entity id when the button is pressed.

It's worth mentioning that since it's a custom map, the button position shouldn't change across wipes, so relative positioning is of questionable value.