Hey, I'm learning how to use oxide and I started yesterday but I'm having trouble finding a function.
First I took a look at Assembly-CSharp.dll and opened the ItemManager class. What I was looking for was a function calledI found this snippet of code from GUIShop. It wasn't there for me, so I kept looking but I couldn't turn up with anything. Where is this function? I know the answer is probably simple but if someone could just push me in the right direction that would be amazing. I also know this code work because I tried it out in game and gave items to my player.Code:ItemManager.CreateByItemID(definition.itemid, giveamount);
P.S sorry for grammar errors I'm really tired
Solved Trying to find a function in ItemManager class
Discussion in 'Rust Development' started by quintee, May 30, 2017.
-
Code:
public static Item CreateByItemID(int itemID, int iAmount = 1, ulong skin = 0L) { ItemDefinition itemDefinition = ItemManager.FindItemDefinition(itemID); if (itemDefinition == null) { return null; } return ItemManager.Create(itemDefinition, iAmount, skin); }
Just go under <default namespace> and then down to ItemManager -
Code:using ProtoBuf; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using UnityEngine;public class ItemManager { public static List<ItemDefinition> itemList; public static Dictionary<int, ItemDefinition> itemDictionary; public static List<ItemBlueprint> bpList; public static int[] defaultBlueprints; public static void Initialize() { if (ItemManager.itemList != null) { return; } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); IEnumerable<GameObject> source = FileSystem.Load<ObjectList>("Assets/items.asset", true).objects.Cast<GameObject>(); if (stopwatch.Elapsed.TotalSeconds > 1.0) { UnityEngine.Debug.Log("Loading Items Took: " + (stopwatch.Elapsed.TotalMilliseconds / 1000.0).ToString() + " seconds"); } List<ItemDefinition> list = (from x in source select x.GetComponent<ItemDefinition>() into x where x != null select x).ToList<ItemDefinition>(); List<ItemBlueprint> list2 = (from x in source select x.GetComponent<ItemBlueprint>() into x where x != null && x.userCraftable select x).ToList<ItemBlueprint>(); Dictionary<int, ItemDefinition> dictionary = new Dictionary<int, ItemDefinition>(); foreach (ItemDefinition current in list) { current.Initialize(list); if (dictionary.ContainsKey(current.itemid)) { ItemDefinition itemDefinition = dictionary[current.itemid]; UnityEngine.Debug.LogWarning(string.Concat(new object[] { "Item ID duplicate ", current.itemid, " (", current.name, ") - have you given your items unique shortnames?" }), current.gameObject); UnityEngine.Debug.LogWarning("Other item is " + itemDefinition.name, itemDefinition); } else { dictionary.Add(current.itemid, current); } } stopwatch.Stop(); if (stopwatch.Elapsed.TotalSeconds > 1.0) { UnityEngine.Debug.Log(string.Concat(new string[] { "Building Items Took: ", (stopwatch.Elapsed.TotalMilliseconds / 1000.0).ToString(), " seconds / Items: ", list.Count.ToString(), " / Blueprints: ", list2.Count.ToString() })); } ItemManager.defaultBlueprints = (from x in list2 where !x.NeedsSteamItem select x.targetItem.itemid).ToArray<int>(); ItemManager.itemList = list; ItemManager.bpList = list2; ItemManager.itemDictionary = dictionary; } public static void UpdateUnlockedSkins() { ItemManager.Initialize(); } public static global::Item Load(ProtoBuf.Item load, global::Item created, bool isServer) { if (created == null) { created = new global::Item(); } created.isServer = isServer; created.Load(load); if (created.info == null) { UnityEngine.Debug.LogWarning("Item loading failed - item is invalid"); return null; } return created; } public static ItemDefinition FindItemDefinition(int itemID) { ItemDefinition result = null; ItemManager.itemDictionary.TryGetValue(itemID, out result); return result; } public static ItemDefinition FindItemDefinition(string shortName) { ItemManager.Initialize(); for (int i = 0; i < ItemManager.itemList.Count; i++) { if (ItemManager.itemList[i].shortname == shortName) { return ItemManager.itemList[i]; } } return null; } public static ItemBlueprint FindBlueprint(ItemDefinition item) { return item.GetComponent<ItemBlueprint>(); } public static List<ItemDefinition> GetItemDefinitions() { ItemManager.Initialize(); return ItemManager.itemList; } public static List<ItemBlueprint> GetBlueprints() { ItemManager.Initialize(); return ItemManager.bpList; } }
-
Are you looking in the Assembly-CSharp.dll that is found in: RustDedicated_Data\Managed ?
-
Where is RustDedicated_Data???
Edit: Gyazo - 89516d6ac770438210bda4883c46a23c.png -
-
Thank you