Discussion in 'Releases' started by watsitfts, Nov 4, 2018.

Approved AutoSackRemover 2018-11-03

Removes loot sack from dead players. Reduces lag in PvP server.

  1. watsitfts
    Offline

    watsitfts Member Member

    Joined:
    Aug 21, 2017
    Messages:
    34
    Likes Received:
    11
    watsitfts submitted a new resource:

    AutoSackRemover - Removes loot sack from dead players. Reduces lag in PvP server.

    Read more about this resource...
     
    #1
  2. ice cold
    Online

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    578
    Likes Received:
    59
    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#
    Code (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);
                        }
                    }
                }
     
    #2
  3. watsitfts
    Offline

    watsitfts Member Member

    Joined:
    Aug 21, 2017
    Messages:
    34
    Likes Received:
    11
    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.
     
    #3
  4. ice cold
    Online

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    578
    Likes Received:
    59
    Np bro and keep up the great work
     
    #4
  5. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,885
    Likes Received:
    677

    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.
    Code (C#):
    List<GameObject> FindObjectsAroundFast(Vector3 givenPosition, float dist = 1f)
    or
    Code (C#):
    List<Entity> FindEntitysAroundFast(Vector3 givenPosition, float dist = 1f)
    Example usage:

    Code (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
        }
    }
     
    #5
  6. ice cold
    Online

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    578
    Likes Received:
    59
    aaay thanks for that bro you just teached me something new ;)
     
    #6
    • Like Like x 1

Share This Page