Help with the plugin

Friends I am a beginner :))) please do not judge harshly, I need your help very much
in the plugin need to create a container to open it with the inventory of the server
put in it loot (it is stone wood and metal fragments) and when closed write to the data file,
when reopening take the data from the data file and put it back into the container (not inventory).
And it seems like a simple task, but I do not understand where to dig and what to do for a week beating reviewed other people's plugins
read a lot of manuscripts, how to create an object understood but further complete dead end...
public class teect : RustPlugin
{
//This is a button
string Gui_ButBack = "[{\"name\":\"Bootionhorse\",\"parent\":\"Overlay\",\"components\":[{\"type\":\"UnityEngine.UI.Image\",\"material\":\"\",\"color\":\"1 0 0 0.3492877\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.65 0.02333333\",\"anchormax\":\"0.835625 0.1477778\",\"offsetmin\":\"0 0\",\"offsetmax\":\"0 0\"}]},{\"name\":\"BtnBack\",\"parent\":\"Bootionhorse\",\"components\":[{\"type\":\"UnityEngine.UI.Button\",\"command\":\"Closebox\",\"color\":\"0 0 0 0.8352941\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.02356893 0.02999994\",\"anchormax\":\"0.9831649 0.9642856\",\"offsetmin\":\"0 0\",\"offsetmax\":\"0 0\"}]},{\"name\":\"txtBootBack\",\"parent\":\"BtnBack\",\"components\":[{\"type\":\"UnityEngine.UI.Text\",\"text\":\"NEXT\",\"fontSize\":24,\"align\":\"MiddleCenter\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.03521138 0.2199999\",\"anchormax\":\"0.9788731 0.8999999\",\"offsetmin\":\"0 0\",\"offsetmax\":\"0 0\"}]}]";

//Create and open a box on command
[ChatCommand("opbox")]//opbox
private void openbox(BasePlayer player)
{
var pos = new Vector3(player.transform.position.x, player.transform.position.y - 1, player.transform.position.z);
string box = "assets/prefabs/deployable/woodenbox/woodbox_deployed.prefab";
var view = GameManager.server.CreateEntity(box, pos) as StorageContainer;
view.GetComponent<GroundWatch>().enabled = true;
//Just playing with the parameters
if (!view) return;
view.limitNetworking = true;
view.transform.position = pos;
view.OwnerID = player.userID;
view.name = "mybox";
view.maxStackSize = 4;
view.inventorySlots = 30;
view.enableSaving = true;
view.buildingID = 123456789;
view.Spawn();
//view.inventory.entityOwner = view;
CuiHelper.AddUi(player, Gui_ButBack);
timer.In(0.1f, delegate ()
{
view.PlayerOpenLoot(player);
});
}
private BaseEntity FindBox(string boxNameOrId)
{
// It doesn’t work anymore I don’t know how ((
BaseEntity box = BaseNetworkable.serverEntities.Find(e => e.name.Contains(boxNameOrId));
if (box != null)
{
return box;
}

uint boxId;
if (uint.TryParse(boxNameOrId, out boxId))
{
box = BaseNetworkable.serverEntities.Find(e => e.net.ID == boxId);
}

return box;
}
}

Thank you in advance for your cooperation..

Please edit your code in a proper code block to be more readable

I tried really hard to do this, but I didn’t understand how :(if you tell me I’ll do it right away, thank you :)

pagan

I tried really hard to do this, but I didn’t understand how :(if you tell me I’ll do it right away, thank you :)


Click {i} and paste the code in the new window.

//This is a button
string Gui_ButBack = "[{\"name\":\"Bootionhorse\",\"parent\":\"Overlay\",\"components\":[{\"type\":\"UnityEngine.UI.Image\",\"material\":\"\",\"color\":\"1 0 0 0.3492877\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.65 0.02333333\",\"anchormax\":\"0.835625 0.1477778\",\"offsetmin\":\"0 0\",\"offsetmax\":\"0 0\"}]},{\"name\":\"BtnBack\",\"parent\":\"Bootionhorse\",\"components\":[{\"type\":\"UnityEngine.UI.Button\",\"command\":\"Closebox\",\"color\":\"0 0 0 0.8352941\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.02356893 0.02999994\",\"anchormax\":\"0.9831649 0.9642856\",\"offsetmin\":\"0 0\",\"offsetmax\":\"0 0\"}]},{\"name\":\"txtBootBack\",\"parent\":\"BtnBack\",\"components\":[{\"type\":\"UnityEngine.UI.Text\",\"text\":\"NEXT\",\"fontSize\":24,\"align\":\"MiddleCenter\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.03521138 0.2199999\",\"anchormax\":\"0.9788731 0.8999999\",\"offsetmin\":\"0 0\",\"offsetmax\":\"0 0\"}]}]";

//Create and open a box on command
[ChatCommand("opbox")]//opbox
private void openbox(BasePlayer player)
{

    var pos = new Vector3(player.transform.position.x, player.transform.position.y - 1, player.transform.position.z);
    string box = "assets/prefabs/deployable/woodenbox/woodbox_deployed.prefab";
    var view = GameManager.server.CreateEntity(box, pos) as StorageContainer;
    view.GetComponent<GroundWatch>().enabled = true;
    //Just playing with the parameters
    if (!view) return;
    view.limitNetworking = true;
    view.transform.position = pos;
    view.OwnerID = player.userID;
    view.name = "mybox";
    view.maxStackSize = 4;
    view.inventorySlots = 30;
    view.enableSaving = true;
    view.buildingID = 123456789;
    view.Spawn();
    //view.inventory.entityOwner = view;
    CuiHelper.AddUi(player, Gui_ButBack);
    timer.In(0.1f, delegate ()
    {
        view.PlayerOpenLoot(player);
    });
}
private BaseEntity FindBox(string boxNameOrId)
{
    // It doesn’t work anymore I don’t know how ((
    BaseEntity box = BaseNetworkable.serverEntities.Find(e => e.name.Contains(boxNameOrId));
    if (box != null)
    {
        return box;
    }

    uint boxId;
    if (uint.TryParse(boxNameOrId, out boxId))
    {
        box = BaseNetworkable.serverEntities.Find(e => e.net.ID == boxId);
    }

    return box;
}


Merged post

omegablue thanks, I didn’t notice this icon :)))) I’ll find out, thanks for the help :)