Elfocrash / L2Autobots

The most advanced L2j bots engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"lsme" not working properly

valanths1990 opened this issue · comments

"lsme"-> { //load and spawn selected on me
this command have issue,
you must keep a reference of bot list, if you dont, coroutine will be executed async but list is cleared before execution

according to your code should be like that:

                   val bots = ViewStates.indexViewState(activeChar).selectedBots.filter { !it.value.isOnline }

                    CoScopes.generalScope.launch {
                        bots.forEach {
                            innerLaunch@CoScopes.massSpawnerScope.launch {
                                val autobot = AutobotsDao.loadByName(it.value.name) ?: return@innerLaunch

                                autobot.setXYZ(activeChar.x + Rnd.get(-150, 150), activeChar.y + Rnd.get(-150, 150), activeChar.z)
                                AutobotsManager.spawnAutobot(autobot)
                            }
                        }
                    }
                    ViewStates.indexViewState(activeChar).selectedBots.clear()

You're right, i remember fixing this at some point. It needs to be async since it can be quite a few bots that you are creating but I can't remember what I did to fix it. Will scan through the private repo and see if I can find it.

In the code i post it fixes that problem

Ah yeah I fixed it like that for the dess command. Thanks I committed it.