1. I searched in forum but nothing help me solving this.

    Well, i dont have much to say. This is my code:
    Code:
    Failed to call hook 'OnItemCraft' on plugin 'TestSkin v1.0.0' (NullReferenceException: Object reference not set to an instance of an object)
    Code:
    using System.Linq;namespace Oxide.Plugins
    {
        [Info("TestSkin", "testing", 1.0)]
        [Description("teeeeeeest")]
        class TestSkin : RustPlugin
        {
            private void Loaded()
            {
                LoadDefaultConfig();
                permission.RegisterPermission("test.testing", this);
            }
               
                private void OnItemCraft(ItemCraftTask task, BasePlayer crafter, BasePlayer player)
                {
                     if (!HasPermission(player, "test.testing")) //I THINK THIS IS THE PROBLEM
                    {
                        SendReply(player, "Normal Cloth");
                        return;
                    }
                    var skins = ItemSkinDirectory.ForItem(task.blueprint.targetItem);
                    if (skins.Count() < 2) return;
                    task.skinID = skins.GetRandom().id;
                }
     
                private void OnItemCraftFinished(ItemCraftTask task, Item item)
                {
                    if (task.amount == 0) return;
                    var skins = ItemSkinDirectory.ForItem(task.blueprint.targetItem);
                    if (skins.Count() < 2) return;
                    task.skinID = skins.GetRandom().id;
                }
        bool HasPermission(BasePlayer player, string perm) => permission.UserHasPermission(player.UserIDString, perm);
        }
    }
    
    Thank you!!!
     
  2. Wulf

    Wulf Community Admin

    Your full error stack in your console/log should show what part is erroring. I would recommend getting familiar with the code you are using instead of copy/pasting code from other plugins. A proper setup in Visual Studio 2015 should also help you with development, debugging, and formatting. From what I can tell, you're trying to call a few things that don't exist in your code above.