Page 1 of 1

Sharing Data between Room Ext and Zone Ext

Posted: 29 Nov 2022, 11:45
by Baiumka
Hello. I can`t get information from Zone Ext in my game-room.

Code: Select all

package ZoneExtension;

    public class ZoneExtension extends SFSExtension{
        private UnitModelFabric unitModelFabric;
        public static ZoneExtension zone;

        @Override
        public void init() {
            zone = this;       
            unitModelFabric = new UnitModelFabric();           
        }

        @Override
        public void destroy()
        {
            super.destroy();
        }
        
        public UnitModelFabric getFabric()
        {
            return unitModelFabric;
        }
    }

Code: Select all

package GameRoomExtension;
public class GameRoomExtension extends SFSExtension {
    @Override
    public void init() {
           int modelCount = ZoneExtension.zone.getFabric().getUnitModelList().size();//Here ZoneExtension.zone is null
    }
}
I already read this thread: https://forums.smartfoxserver.com/viewtopic.php?t=11643 but it seems too old. I not found .javaExtension/ in any config. Please help me.

P.S. Sorry for my bad knowlage of language.

Re: Sharing Data between Room Ext and Zone Ext

Posted: 30 Nov 2022, 16:17
by Lapo
Hi,
the article you have linked to is for SmartFoxServer 1.x while you're working with SmartFoxServer 2X.

You can check the documentation here:
http://docs2x.smartfoxserver.com/Extens ... assLoading

The section I have linked explains how Extension work behind the scenes and how to deal with scenarios like the one you have posted.

Cheers