AutoSackRemover

Approved AutoSackRemover 2018-11-03

No permission to download

ice cold

Active Member
Member
Oct 24, 2016
610
95
28
Canada
Clearing Inventory when a player dies wil cause the isue that on spawn his inventory wil be empty indeed
(I've tried this method by myself)

here some working code for C#
C#:
    private void DestroySacks(User victim)
        {
            foreach(LootableObject lb in UnityEngine.Resources.FindObjectsOfTypeAll<LootableObject>())
            {
              
                if(lb.gameObject.name == "LootSack(Clone)")
                {
                    float dist = Vector3.Distance(victim.Location, lb.transform.position);

                    if(dist < 5f)
                    {
                        NetCull.Destroy(lb.gameObject);
                    }
                }
            }
 

watsitfts

Member
Member
Aug 21, 2017
57
16
8
38
Parts Unknown
Hi IceCold. Nice. Maybe you can to make a plugin use it.... About "Clearing Inventory when a player dies wil cause the isue that on spawn his inventory wil be empty indeed" only happen if admin use any reload command (test in my server...). If NOT use reload commands... AutoSackRemover work perfect(in my server). But maybe you found any conflict... if automatic spawn kit NOT wait 0.03 seconds... maybe risk give and clear kit same time in spawn... I see sometimes this problem... then I recommend wait small time before give automatic kit after player spawn. Your idea I believe more efficient. Very thanks IceCold.
 

ice cold

Active Member
Member
Oct 24, 2016
610
95
28
Canada
Hi IceCold. Nice. Maybe you can to make a plugin use it.... About "Clearing Inventory when a player dies wil cause the isue that on spawn his inventory wil be empty indeed" only happen if admin use any reload command (test in my server...). If NOT use reload commands... AutoSackRemover work perfect(in my server). But maybe you found any conflict... if automatic spawn kit NOT wait 0.03 seconds... maybe risk give and clear kit same time in spawn... I see sometimes this problem... then I recommend wait small time before give automatic kit after player spawn. Your idea I believe more efficient. Very thanks IceCold.
Np bro and keep up the great work
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
3,937
1,060
113
Hungary
github.com
Clearing Inventory when a player dies wil cause the isue that on spawn his inventory wil be empty indeed
(I've tried this method by myself)

here some working code for C#
C#:
    private void DestroySacks(User victim)
        {
            foreach(LootableObject lb in UnityEngine.Resources.FindObjectsOfTypeAll<LootableObject>())
            {
         
                if(lb.gameObject.name == "LootSack(Clone)")
                {
                    float dist = Vector3.Distance(victim.Location, lb.transform.position);

                    if(dist < 5f)
                    {
                        NetCull.Destroy(lb.gameObject);
                    }
                }
            }

Hi IceCold. Nice. Maybe you can to make a plugin use it.... About "Clearing Inventory when a player dies wil cause the isue that on spawn his inventory wil be empty indeed" only happen if admin use any reload command (test in my server...). If NOT use reload commands... AutoSackRemover work perfect(in my server). But maybe you found any conflict... if automatic spawn kit NOT wait 0.03 seconds... maybe risk give and clear kit same time in spawn... I see sometimes this problem... then I recommend wait small time before give automatic kit after player spawn. Your idea I believe more efficient. Very thanks IceCold.
The Resources in not good to use at that point.

"This function can return any type of Unity object that is loaded, including game objects, prefabs, materials, meshes, textures, etc. It will also list internal stuff, therefore please be extra careful the way you handle the returned objects. Contrary to Object.FindObjectsOfType this function will also list disabled objects.

Please note that this function is very slow and is not recommended to be used every frame."

UnityEngine.Object can be better.

However, that's also fucked up, and slow.
C#:
List<GameObject> FindObjectsAroundFast(Vector3 givenPosition, float dist = 1f)
or
C#:
List<Entity> FindEntitysAroundFast(Vector3 givenPosition, float dist = 1f)
Example usage:

C#:
List<GameObject> ls = Util.GetUtil().FindObjectsAroundFast(victim.Location, 5f);
foreach (var x in ls)
{
    if (ls.GetComponent<LootableObject>() != null)
    {
        // Maybe check the name of the gameobject, because a lootable object can be a chest too.
        NetCull.Destroy(x);
        //break; // uncomment if we need to remove only one
    }
}
 

ice cold

Active Member
Member
Oct 24, 2016
610
95
28
Canada
The Resources in not good to use at that point.

"This function can return any type of Unity object that is loaded, including game objects, prefabs, materials, meshes, textures, etc. It will also list internal stuff, therefore please be extra careful the way you handle the returned objects. Contrary to Object.FindObjectsOfType this function will also list disabled objects.

Please note that this function is very slow and is not recommended to be used every frame."

UnityEngine.Object can be better.

However, that's also fucked up, and slow.
C#:
List<GameObject> FindObjectsAroundFast(Vector3 givenPosition, float dist = 1f)
or
C#:
List<Entity> FindEntitysAroundFast(Vector3 givenPosition, float dist = 1f)
Example usage:

C#:
List<GameObject> ls = Util.GetUtil().FindObjectsAroundFast(victim.Location, 5f);
foreach (var x in ls)
{
    if (ls.GetComponent<LootableObject>() != null)
    {
        // Maybe check the name of the gameobject, because a lootable object can be a chest too.
        NetCull.Destroy(x);
        //break; // uncomment if we need to remove only one
    }
}
aaay thanks for that bro you just teached me something new ;)
 
  • Like
Reactions: DreTaX