Crash when spawning entities from OnLevelInit
Posted: Sun Dec 17, 2017 12:34 am
It seems that trying to spawn entities from the OnLevelInit listener will crash the server.
I need my plugin to be able to spawn several entities on map start before players are able to play. Is there another listener I can use that is called after the level is properly loaded and ready for entities?
Syntax: Select all
from commands.typed import TypedSayCommand
from entities._base import Entity
from players._base import Player
from listeners import OnLevelInit
from mathlib import Vector
@TypedSayCommand('add')
def on_add(command_info, classname:str):
ent = Entity.create(classname)
player = Player(command_info.index)
ent.origin = player.view_coordinates + Vector(0, 0, 32)
ent.spawn()
@OnLevelInit
def on_level(map_name):
ent = Entity.create('item_defuser')
ent.origin = Vector(500, 0, 100)
ent.spawn()
I need my plugin to be able to spawn several entities on map start before players are able to play. Is there another listener I can use that is called after the level is properly loaded and ready for entities?