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:
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?Code:if (player.inventory.containerBelt <contains> workbench3) player.currentCraftLevel = <whatever workbench3 grants>
Plugin Help - Workbench in Belt, allows you to craft anywhere.
Discussion in 'Rust Development' started by KittyMeowMeow, Nov 19, 2017.
-
What about finding items:
Code:BasePlayer player = new BasePlayer(); if (player.inventory.AllItems().Contains(ItemManager.CreateByName("IDontRememberName"))) { //something }
Last edited by a moderator: Nov 19, 2017 -
Does
Code:if (player.inventory.containerBelt.Contains(ItemManager.CreateByName("workbench3")))
then just
Code:player.currentCraftLevel
-
If you want realize this, you should create new Trigger, and forced to put the player there.
player.EnterTrigger(Trigger); -
Where should I look to learn more about Triggers??? -
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; } } } }
-
That if seems wrong to me...
I think you should change thisCode:if (container == player.inventory.containerBelt) && (item.name == "workbench3")
Code:if (container == player.inventory.containerBelt && item.name == "workbench3")
-
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. <3Last edited by a moderator: Nov 20, 2017 -
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 -
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