Page 1 of 1

ObjectCreatedCallback does not work without ObjectTerminatedCallback

Posted: Thu Aug 08, 2019 3:03 pm
by NearHuscarl

Code: Select all

        public void OnStartup()
        {
            Events.ObjectCreatedCallback.Start(OnObjectCreated);
            // Uncomment the line below and it will work again
            // Events.ObjectTerminatedCallback.Start(OnObjectTerminated);
        }

        public void OnObjectCreated(IObject[] objs)
        {
            foreach (IObject obj in objs)
            {
                Game.WriteToConsole(string.Format("Object {0} ({1}) created", obj.UniqueID, obj.Name));
            }
        }

        public void OnObjectTerminated(IObject[] objs)
        {
            // objects terminated. Note: This is run just before the object is about to be destroyed or removed. To see if it was destroyed, check the IObject.DestructionInitiated property.
            foreach (IObject obj in objs)
            {
                Game.WriteToConsole(string.Format("Object {0} was {1}", obj.UniqueID, (obj.DestructionInitiated ? "destroyed" : "removed")));
            }
        }
Events.ObjectCreatedCallback doesn't register the callback event. Only work if you add an object terminated callback event alongside with it

Re: ObjectCreatedCallback does not work without ObjectTerminatedCallback

Posted: Sat Aug 10, 2019 10:13 am
by Gurt
Fixed after v.1.3.0b