Check entity in OnEntityTakeDamage
Discussion in 'Rust Development' started by Equiment, Feb 21, 2016.
-
I haven't tested this but it should point you in the right direction:
Be sure to check out the docs.Code:void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info) { Item item = entity.GetItem(); if (item.info.itemid == -496055048) // High ext stone wall id { // Do something } } -
[DOUBLEPOST=1456098036][/DOUBLEPOST]Okay, i found the solutionCode:
[Oxide] 2:30 AM [Error] Failed to call hook 'OnEntityTakeDamage' on plugin 'SACore v0.1.0' (NullReferenceException: Object reference not set to an instance of an object) [Oxide] 2:30 AM [Debug] at Oxide.Plugins.SACore.OnEntityTakeDamage (.BaseCombatEntity entity, .HitInfo info) [0x00000] in <filename unknown>:0 at Oxide.Plugins.SACore.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (System.Reflection.MethodInfo 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 hookname, System.Object[] args) [0x00000] in <filename unknown>:0
if (entity.name.Contains("wall.external.high.stone"))Last edited by a moderator: Feb 21, 2016 -
Calytic Community Admin Community Mod
Be advised that OnEntityTakeDamage is called very often. There is a substantial benefit to checking by prefabID rather than doing a string operation.
You can find the entityPrefabID fairly easily..Code:void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info) { if (entity.prefabID == entityPrefabID) // High ext stone wall id { // Do something } }
Code:void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info) { PrintWarning(entity.prefabID); }
