Hello eveyone. I have these code in my plugin. They works fine but console keep showing errors below. Can anyone help me with it? Thanks!
private void OnEntityKill(BaseNetworkable entity)
{
if (entity != null)
{
if (entity.ShortPrefabName == "sleepingbag_leather_deployed" || entity.ShortPrefabName == "bed_deployed")
{
SleepingBag bag = (SleepingBag)(entity as BaseEntity);
var player = BasePlayer.FindByID(bag.OwnerID);
var BagId = bag.net.ID;
playerCache[player.userID].RemoveEntry(player, bag.net.ID);
SaveData();
}
}
}private void OnEntitySpawned(BaseNetworkable entity)
{
if (entity != null)
{
if (entity.ShortPrefabName == "sleepingbag_leather_deployed" || entity.ShortPrefabName == "bed_deployed")
{
SleepingBag bag = (SleepingBag)(entity as BaseEntity);
var player = BasePlayer.FindByID(bag.OwnerID);
var BagId = bag.net.ID;
if (!playerCache.ContainsKey(player.userID))
{
playerCache[player.userID] = new PlayerData(player, bag.transform.position, BagId, bag.niceName);
}
else
{
playerCache[player.userID].AddEntry(player, bag.transform.position, BagId, bag.niceName);
}
SaveData();
}
}
}Errors are:
Failed to call hook 'OnEntitySpawned' on plugin 'MCmenu3 v0.0.1' (NullReferenceException: Object reference not set to an instance of an object)
at Oxide.Plugins.MCmenu3.OnEntitySpawned (BaseNetworkable entity) [0x0005a] in <92a5e2b90d444c829b982413513147d8>:0
at Oxide.Plugins.MCmenu3.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00a19] in <92a5e2b90d444c829b982413513147d8>:0
at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <60c318df79ed41688ea59335e48d61ad>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <9882f28dc2204b4dba514a9ad18f5042>:0
at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <9882f28dc2204b4dba514a9
Failed to call hook 'OnEntityKill' on plugin 'MCmenu3 v0.0.1' (NullReferenceException: Object reference not set to an instance of an object)
at Oxide.Plugins.MCmenu3.OnEntityKill (BaseNetworkable entity) [0x0005a] in <92a5e2b90d444c829b982413513147d8>:0
at Oxide.Plugins.MCmenu3.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00a47] in <92a5e2b90d444c829b982413513147d8>:0
at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <60c318df79ed41688ea59335e48d61ad>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <9882f28dc2204b4dba514a9ad18f5042>:0
at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <9882f28dc2204b4dba514a9>