Jump to content

Satchel thing for drop items


Soller

Recommended Posts

Once on some server I saw that all dropped items are combined into a satchel thing. Since I haven't seen anything like this anywhere else, I think this is a personal plugin. Can someone write the same plugin and put it on codefiling? Maybe I'm calling this gray bag incorrectly, its prefab is called item_drop.prefab.

Link to comment
Share on other sites

20 hours ago, Krungh Crow said:

this is default rust behavior drops items from container as a drop bag

No, I'm not talking about when the box with the items was broken and the bag appeared. I'm talking about the fact that when a player throws any items out of the inventory, they all end up in a gray bag. For example, I will throw SAR, cartridges and grenades out of the inventory, and it will all end up in a gray bag.

Link to comment
Share on other sites

2 minutes ago, Krungh Crow said:

its more a thing to find what plugin you have that allready does this since it is not normal behaviour

We seem to have translation difficulties, English is not my native language. I'm not looking for a plugin that does something with the OnitemDrop hook on my server, I don't have one. I just saw on one server how all dropped items are combined into one gray bag. And I wanted to find the same plugin, or someone who will make such a plugin and post it here on codefiling.

Link to comment
Share on other sites

Lol, I asked artificial intelligence to write this plugin. The AI even did something. It's a pity that this plugin doesn't do anything.)
 

using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("ItemDropPlugin", "ChatGPT", "1.0.0")]
    class ItemDropPlugin : RustPlugin
    {
        // Your existing code...

        void OnLootEntity(BasePlayer player, BaseEntity entity)
        {
            if (entity is WorldItem)
            {
                WorldItem worldItem = (WorldItem)entity;
                Item item = worldItem.item;

                if (item != null)
                {
                    Puts($"{player.displayName} dropped item: {item.info.displayName.translated}");

                    string prefabName = "item_drop.prefab";
                    GameObject targetPrefab = GameManager.server.FindPrefab(prefabName);

                    if (targetPrefab != null)
                    {
                        // Instantiate the target prefab using a separate script
                        ItemDropPrefabScript.Instance.SpawnItemDropPrefab(worldItem.transform.position, targetPrefab, item);
                        
                        // Destroy the original dropped item
                        worldItem.Kill();
                    }
                    else
                    {
                        Puts($"Prefab not found: {prefabName}");
                    }
                }
            }
        }
    }

    // MonoBehaviour script for handling prefab instantiation
    class ItemDropPrefabScript : MonoBehaviour
    {
        public static ItemDropPrefabScript Instance;

        private void Awake()
        {
            Instance = this;
        }

        public void SpawnItemDropPrefab(Vector3 position, GameObject prefab, Item item)
        {
            GameObject itemDropPrefab = Instantiate(prefab, position, Quaternion.identity);
            Item newItem = itemDropPrefab.GetComponent<Item>();

            if (newItem != null)
            {
                newItem.info = item.info;
                newItem.amount = item.amount;
            }
            else
            {
                Debug.LogError("Failed to get Item component from the instantiated prefab.");
            }
        }
    }
}
Link to comment
Share on other sites

15 hours ago, Soller said:

Lol, I asked artificial intelligence to write this plugin. The AI even did something. It's a pity that this plugin doesn't do anything.)
 

using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("ItemDropPlugin", "ChatGPT", "1.0.0")]
    class ItemDropPlugin : RustPlugin
    {
        // Your existing code...

        void OnLootEntity(BasePlayer player, BaseEntity entity)
        {
            if (entity is WorldItem)
            {
                WorldItem worldItem = (WorldItem)entity;
                Item item = worldItem.item;

                if (item != null)
                {
                    Puts($"{player.displayName} dropped item: {item.info.displayName.translated}");

                    string prefabName = "item_drop.prefab";
                    GameObject targetPrefab = GameManager.server.FindPrefab(prefabName);

                    if (targetPrefab != null)
                    {
                        // Instantiate the target prefab using a separate script
                        ItemDropPrefabScript.Instance.SpawnItemDropPrefab(worldItem.transform.position, targetPrefab, item);
                        
                        // Destroy the original dropped item
                        worldItem.Kill();
                    }
                    else
                    {
                        Puts($"Prefab not found: {prefabName}");
                    }
                }
            }
        }
    }

    // MonoBehaviour script for handling prefab instantiation
    class ItemDropPrefabScript : MonoBehaviour
    {
        public static ItemDropPrefabScript Instance;

        private void Awake()
        {
            Instance = this;
        }

        public void SpawnItemDropPrefab(Vector3 position, GameObject prefab, Item item)
        {
            GameObject itemDropPrefab = Instantiate(prefab, position, Quaternion.identity);
            Item newItem = itemDropPrefab.GetComponent<Item>();

            if (newItem != null)
            {
                newItem.info = item.info;
                newItem.amount = item.amount;
            }
            else
            {
                Debug.LogError("Failed to get Item component from the instantiated prefab.");
            }
        }
    }
}

OnLootEntity hook gets called whenever player is looting an entity, not when player is dropping items

Link to comment
Share on other sites

11 hours ago, Zeeuss said:

OnLootEntity hook gets called whenever player is looting an entity, not when player is dropping items

It's not clear to me. I don't write plugins. I'm not looking for help writing a plugin. I just suggested that one of the developers write a plugin that does what I described above. And would post this plugin here on codefiling.

Link to comment
Share on other sites

On 12/4/2023 at 7:28 PM, Soller said:

It's not clear to me. I don't write plugins. I'm not looking for help writing a plugin. I just suggested that one of the developers write a plugin that does what I described above. And would post this plugin here on codefiling.

Write to me in discord mbstudios
And send me more information about what you need

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
1.1m

Downloads

Total number of downloads.

5.7k

Customers

Total customers served.

82.1k

Files Sold

Total number of files sold.

1.6m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.