Share examples of

Demo

Member
Member
Mar 3, 2016
108
14
18
28
Parts Unknown
On_ItemAdded
On_ItemPickup
On_ItemRemoved

wiki is not a single example (

P.S Still need assistance - want to get with craft a couple of things - I having in the. ini all the crafts send them to the server?Suppose to craft any thing else and the plugin itself is looking for his list in the ini
 
Last edited:

DFM Москва 101.2

Member
Member
Aug 23, 2016
66
-2
6
28
Parts Unknown
C#:
public void On_ItemAdded(InventoryModEvent e)
{

}

public void On_ItemRemoved(InventoryModEvent e)
{

}

public void ItemPickup(ItemPickupEvent ipe)
{
  
}
Can you answer these two questions?
Let's say I have in the config file there is a list of things to craft

[M4]
Item1=Stones,1
Item2=Wood,6

How can I simplify the code to the server, he checked how many items you need for crafting?Item1,Item2 and so on for each subject

Now write your module - hodgepodge.
Do check the player's name - if the name is not correct SteamID - kicks,But I get the error (
nullreferenceexception object reference not set to an instance of an object

C#:
if (p.ClientConnection.UserName != CheckName.GetSetting(Convert.ToString(p.ClientConnection.UserID), "UserName"))
            {
                p.ClientConnection.netUser.Kick(NetError.Facepunch_Kick_RCON, true);
            }
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
C#:
//[Items]
//M4=Stones,1|Wood,6
//P250=Wood,6


Dictionary<string, Dictionary<string, int>> Datas = new Dictionary<string, Dictionary<string, int>>();

public void LoadStuff()
{
    IniParser ini = new IniParser(ModuleFolder + "\\Settings.ini");
    foreach (var x in ini.EnumSection("Items"))
    {
        var d = ini.GetSetting("Items", x);
        var split = d.Split('|');
        foreach (var y in split)
        {
            var split2 = y.Split(',');
            Datas[split2[0]] = int.Parse(split2[1]);
        }
    }
}

//var dict = GetDataForItem("M4");
public Dictionary<string, int> GetDataForItem(string name)
{
    foreach (var x in Datas.Keys) {
        if (x == name) {
            return x;
        }
    }
    return null;
}
 

DFM Москва 101.2

Member
Member
Aug 23, 2016
66
-2
6
28
Parts Unknown
C#:
//[Items]
//M4=Stones,1|Wood,6
//P250=Wood,6


Dictionary<string, Dictionary<string, int>> Datas = new Dictionary<string, Dictionary<string, int>>();

public void LoadStuff()
{
    IniParser ini = new IniParser(ModuleFolder + "\\Settings.ini");
    foreach (var x in ini.EnumSection("Items"))
    {
        var d = ini.GetSetting("Items", x);
        var split = d.Split('|');
        foreach (var y in split)
        {
            var split2 = y.Split(',');
            Datas[split2[0]] = int.Parse(split2[1]);
        }
    }
}

//var dict = GetDataForItem("M4");
public Dictionary<string, int> GetDataForItem(string name)
{
    foreach (var x in Datas.Keys) {
        if (x == name) {
            return x;
        }
    }
    return null;
}
Unfortunately your code for me so far is complex :( - you can simplify?I want to make a modified craft.You can simplify?I want to make a modified crafting?

C#:
if (e.ItemName == "M4")
{
      if(!e.Player.Inventory.HasItem(Datas[split2[0]] || !e.Player.Inventory.HasItem(Datas[split2[1]]))
       {
             e.Player.Message("No ingredient");
       }
}
about the inventory entity - it crashes ( although the name in the chat writes

item.Drop();
 
Last edited: