Getting a InvalidCastException when any CanBuild hook in any plugin is called. For instance:
[DOUBLEPOST=1513897010][/DOUBLEPOST]Just a note to any other plugin authors, you can just omit the final argument and the hook works fine.Code:Failed to call hook 'CanBuild' on plugin 'BuildingBlocker v1.0.0' (InvalidCastException: Value is not a convertible object: UnityEngine.Vector3 to Construction+Target) at System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) [0x00000] in <filename unknown>:0 at System.Convert.ChangeType (System.Object value, System.Type conversionType) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0
Solved CanBuild hook broken (old hook)
Discussion in 'Rust Development' started by theconezone, Dec 21, 2017.
-
Wulf Community Admin
Which signature are you implementing in your plugin?
-
object CanBuild(Planner planner, Construction prefab, Vector3 position) as per the documentation
[DOUBLEPOST=1513897316][/DOUBLEPOST]Ahh, I see the hook changes in the opj. I should've checked that as well. -
Is anyone else still getting this issue? I still get the exception with CanBuild(Planner, Construction, Construction.Target) or object CanBuild(Planner, Construction, Vector3), but not CanBuild(Planner, Construction)
-
Wulf Community Admin
-
Code:object CanBuild(Planner plan, Construction prefab, object obj) { if (obj is Construction.Target) { var target = (Construction.Target)obj; // .... } else { var position = (Vector3)obj; // ... } return null; // or anything else needed }
-