1. I'm trying to loop through a list of entities...save them to a list for later use then restore them back to original upon command any tips on doing this?
     
  2. I think you'll have to save the info about the entities, then respawn them later. Like prefab path, health, any other properties they may have. You may be able to store them in a list/dictionary temporarily, but if you're wanting to save it to a file or have it persist over a plugin reload or server restart, I'm 99% sure you'd have to save the info of them, rather than the entity itself.
     

  3. I am wanting to save information and such about entities in a list temporarily and then load them back onto the map when called could you give me an example of how to do that ?
     
  4. Create a class to store your all your variables. For example, in EventManager I store information for each item in the players inventory so it can be restored after the match

    Code:
    List<EventInvItem> items = new List<EventInvItem>();public class EventInvItem
            {
                public int itemid;
                public int skin;
                public string container;
                public int amount;
                public float condition;
                public int ammo;            
            }    // Add to it like this;
    items.Add(new EventInvItem
                    {
                        itemid = item.info.itemid,
                        container = containerName,
                        amount = item.amount,
                        ammo = (item.GetHeldEntity() as BaseProjectile)?.primaryMagazine.contents ?? 0,
                        skin = item.skin,
                        condition = item.condition                   
                    });
    
    Once the match is over I re-create all the items using the stored variables and put them back in the players inventory. You can do this for anything really, just keep the information you need (position, entity type, etc)
     
  5. Code:
            public class entityData{
                public BaseEntity obj;
                public float pos;
                public float rot;
            }
    
    I'm just trying to store deployables / buildings

    Not items what variable types are entity.transform.position and entity.transform.rotation ?

    how could i store that information in the class properly?

    Also how could i saved them to a list Ex:

    Code:
    public Dictionary<ulong, string> savedEntities = new Dictionary<ulong, string>();savedEntities.Add(new entityData(entity, entity.transform.position, entity.transform.rotation));
    
    ?? any help would be appreciated thanks.


    I'm also trying to respawn them on the map by looping through savedEntities. ex:

    Code:
            private void regenMap(){
                foreach(var entity in savedEntities)
                {
                    new Entity
                   entity.transform.position = savedEntities["entity.transform.position"]; etc
                }
            }
    
     
  6. I know your not saving items that was just a example. I would store the position, rotation and prefab path. I'm not home, this is a phone edit off the top of my head so may be some mistakes. Again this is just a example to get you started

    Code:
    class BlockInfo
    {
       public string PrefabName;
       public Vector3 Position;
       public Quaternion Rotation;
    }List<BlockInfo> BlockInformation = new List<BlockInfo>();void SaveBlockInfo(List<BuildingBlock> blocks)
    {
       foreach (var block in blocks)
       {
          BlockInformation.Add(new BlockInfo{ PrefabName = block.LookupPrefabName(), Position = block.transform.position, Rotation = block.transform.rotation });
       }
    }
    void RestoreBlocks()
    {
       foreach (var block in BlockInformation)
       {
          BaseEntity newBlock = GameManager.server.CreateEntity(block.PrefabName, block.Position, block.Rotation);
               newBlock.Spawn();
       }
    }
     
  7. Thankyou so much I got it working great.

    I just need to read more into the assembly dll and crap to get all these functions im unaware of :/ and data types.