1. Hello,

    I had an idea for a plugin, and I thought I could figure out how to write it... I've edited plugins before, but never written anything from scratch.

    Basically, I would love to write a plugin that would grant players Workbench3 privilege as long as they had a workbench3 in their belt...

    My initial thoughts were:

    Code:
    if (player.inventory.containerBelt  <contains>  workbench3)
           player.currentCraftLevel = <whatever workbench3 grants>
    
    So, obviously I don't actually know how to search the belt for the item, or what values player.currentCraftLevel takes... Any help, pretty please?
     
  2. What about finding items:
    Code:
    BasePlayer player = new BasePlayer();
    if (player.inventory.AllItems().Contains(ItemManager.CreateByName("IDontRememberName")))
    {
            //something      
    }
    What about craftLvl, you can use code from: NoWorkbench for Rust | Oxide
     
    Last edited by a moderator: Nov 19, 2017
  3. I'll check out NoWorkbench -- I've been looking at it, but I can't find what I want: yet!

    Does

    Code:
    if (player.inventory.containerBelt.Contains(ItemManager.CreateByName("workbench3"))) 
    Work???


    then just

    Code:
     player.currentCraftLevel 
    ?
     
  4. Check in OxideAPI pls (but i think yes), and player.currentCraftLevel is only to Get.
    If you want realize this, you should create new Trigger, and forced to put the player there.

    player.EnterTrigger(Trigger);
     
  5. Yeah, I was seeing all that stuff about Triggers -- in the NoWorkbench Plugin, they use a lot of that, and I don't really understand...

    Where should I look to learn more about Triggers???
     
  6. This is what I have right now... and it's definitely not working... (Error while compiling... unexpected symbol { )

    So yeah.



    Code:
    using Newtonsoft.Json;
    using System.Reflection;
    using UnityEngine;namespace Oxide.Plugins
    {
        [Info("PortableWorkbench", "kittymeowmeow", "0.0.01")]
        class PortableWorkbench : RustPlugin
        {      private void OnServerInitialized()
            {
                LoadVariables();        }      void OnItemAddedToContainer(ItemContainer container, Item item)
            {
              if (container == player.inventory.containerBelt) && (item.name == "workbench3")
                {
                  player.currentCraftLevel = 3f;
                }        }      }
    }
    
    Any help pretty please??
     
  7. That if seems wrong to me...
    I think you should change this
    Code:
    if (container == player.inventory.containerBelt) && (item.name == "workbench3")
    to this
    Code:
    if (container == player.inventory.containerBelt && item.name == "workbench3")
     
  8. yup. That was definitely wrong. xD

    I'm really just shooting in the dark, here...

    This is what I'm working with now...


    Code:
    using Newtonsoft.Json;
    using System;
    using UnityEngine;
    using Rust;namespace Oxide.Plugins
    {
        [Info("PortableWorkbench", "kittymeowmeow", "0.0.01")]
        class PortableWorkbench : RustPlugin
        {
          BasePlayer player       void OnServerInitialized()
            {
                LoadVariables();        }      void OnItemAddedToContainer(ItemContainer container, Item item)
            {
              if (container == player.inventory.containerBelt && item.name == "workbench3")
                {
                  player.currentCraftLevel = 3f;
                }        }      void OnItemRemovedFromContainer(ItemContainer container, Item item)
            {
              if (player.triggers == null)
                {
                    return 0f;
                }
              if (player.nextCheckTime > Time.realtimeSinceStartup)
              {
                  return player.cachedCraftLevel;
              }
              player.nextCheckTime = Time.realtimeSinceStartup + Random.Range(0.4f, 0.5f);
              float single = 0f;
              for (int i = 0; i < player.triggers.Count; i++)
              {
                  TriggerWorkbench workbenchItem = player.triggers[i] as TriggerWorkbench;
                  if (item != null)
                  {
                      if (workbenchItem.parentBench != null)
                      {
                          if (workbenchItem.parentBench.IsVisible(player.eyes.position))
                          {
                              float single1 = workbenchitem.WorkbenchLevel();
                              if (single1 > single)
                              {
                                  single = single1;
                              }
                          }
                      }
                  }
              }
              player.cachedCraftLevel = single;
            }      }
    }
    

    Again, really just shooting in the dark...

    Getting

    "Error while compiling: PortableWorkbench.cs(14,11): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration"

    --- edit: the above error was because of a missing ; /// sorta? -- I know I'm still way off... looking for help would be great. <3
     
    Last edited by a moderator: Nov 20, 2017
  9. line 11 needs fixed I dont have visual studio installed but I am sure there are more
     
    Last edited by a moderator: Nov 20, 2017
  10. There's ; missing at line 11... You might wanna start using visual studio, completely eliminates syntax mistakes
     
    Last edited by a moderator: Nov 20, 2017