1. Hello,

    I am pretty new to OO languages and I am spending some time when it's available to progress my learning, I am creating a plugin that I thought was working but the variable only seems to update once. I'm guessing it's because it's being declared once at startup but I don't know the OO way of doing it.

    How would I update the variable before each save?

    Code:
        class EntityCounter : RustPlugin
        {
          
            private int EntityCount = BaseNetworkable.serverEntities.Count;
            private int MaxEntity = 250000;
      
        void OnServerSave()
        {
            int Remaining = MaxEntity - EntityCount;
          
            if (EntityCount < MaxEntity){            PrintToChat("Total Entities : {0}, Wipe @ {1}. Remaining Entities to go {2}", 
            }
            else {
                PrintToChat("Entity Limit Reached! Admin will be wiping soon.");
            }
          
        }
        }
     
  2. Wulf

    Wulf Community Admin

    The hook is just a trigger that gets called, it wouldn't be your issue.
     
  3. Yeah I know, I think I named the title incorrectly ;) I've just not delved into public, private etc yet and I'm wondering how I could get it to be updated when that trigger is called.
     
  4. Wulf

    Wulf Community Admin

    Your issue is that you are only setting the entity count when the plugin is loaded, so it will never change. You should be checking it each time the hook is called.
     
  5. Yeah I knew that but I've figured it out now, Got my book out and did some reading, I appreciate you didn't give me the quick fix.