Esempio n. 1
0
 def ListenEvent(self):
     # 服务端脚本自定义了3个事件,用于通知所有的监听了这个事件的客户端
     # PlayShootAnimEvent 用于通知客户端在射击时播放玩家的骨骼动画
     # BulletFlyFrameEvent 用于通知客户端在设计时给子弹绑定特效
     # BulletHitEvent 用于通知客户端子弹击中了目标并返回给客户端一些击中信息
     self.DefineEvent(modConfig.PlayShootAnimEvent)
     self.DefineEvent(modConfig.BulletFlyFrameEvent)
     self.DefineEvent(modConfig.BulletHitEvent)
     # 服务器端脚本监听了引擎的4个事件,分别为 ServerChatEvent / ScriptTickServerEvent / AddServerPlayerEvent / ProjectileDoHitEffectEvent
     # 具体每个事件的详细事件data可以参考《MODSDK文档》
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(),
                         modConfig.ServerChatEvent, self, self.OnServerChat)
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(),
                         modConfig.ScriptTickServerEvent, self,
                         self.OnTickServer)
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(),
                         modConfig.AddServerPlayerEvent, self,
                         self.OnPlayerAdd)
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(),
                         modConfig.ProjectileDoHitEffectEvent, self,
                         self.OnProjectileHit)
     # 服务端脚本监听了客户端自定义的事件 ShootEvent
     self.ListenForEvent(modConfig.ModName, modConfig.ClientSystemName,
                         modConfig.ShootEvent, self, self.OnShoot)
Esempio n. 2
0
 def UnListenEvent(self):
     # 取消自定义的3个事件
     self.UnDefineEvent(modConfig.PlayShootAnimEvent)
     self.UnDefineEvent(modConfig.BulletFlyFrameEvent)
     self.UnDefineEvent(modConfig.BulletHitEvent)
     # 取消监听4个系统事件
     self.UnListenForEvent(serverApi.GetEngineNamespace(),
                           serverApi.GetEngineSystemName(),
                           modConfig.ServerChatEvent, self,
                           self.OnServerChat)
     self.UnListenForEvent(serverApi.GetEngineNamespace(),
                           serverApi.GetEngineSystemName(),
                           modConfig.ScriptTickServerEvent, self,
                           self.OnTickServer)
     self.UnListenForEvent(serverApi.GetEngineNamespace(),
                           serverApi.GetEngineSystemName(),
                           modConfig.AddServerPlayerEvent, self,
                           self.OnPlayerAdd)
     self.UnListenForEvent(serverApi.GetEngineNamespace(),
                           serverApi.GetEngineSystemName(),
                           modConfig.ProjectileDoHitEffectEvent, self,
                           self.OnProjectileHit)
     # 取消监听客户端事件
     self.UnListenForEvent(modConfig.ModName, modConfig.ClientSystemName,
                           modConfig.ShootEvent, self, self.OnShoot)
Esempio n. 3
0
    def __init__(self, *args):
        super(Srv, self).__init__(*args)
        self.ListenForEvent(serverApi.GetEngineNamespace(),
                            serverApi.GetEngineSystemName(),
                            'AddServerPlayerEvent', self, self.connection_made)
        self.ListenForEvent(serverApi.GetEngineNamespace(),
                            serverApi.GetEngineSystemName(),
                            'DelServerPlayerEvent', self, self.connection_lost)
        self.ListenForEvent(serverApi.GetEngineNamespace(),
                            serverApi.GetEngineSystemName(),
                            'LoadServerAddonScriptsAfter', self,
                            self.serve_forever)
        self.ListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_CLI_NAME, 'G_DEBUT',
                            self, self.debut)
        self.ListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_CLI_NAME, 'G_MATCH',
                            self, self.match)
        self.ListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_CLI_NAME, 'G_COURT',
                            self, self.rcall)

        self.CreateComponent(serverApi.GetLevelId(), 'Minecraft',
                             'game').OpenCityProtect()

        self.s = set()
        self._mapping = {}
        self._q = Queue()
        self._alive = True
        self._consumer = kafka.KafkaConsumer('duel',
                                             bootstrap_servers=KAFKA_SERVERS,
                                             value_deserializer=pickle.loads)
        self._producer = kafka.KafkaProducer(bootstrap_servers=KAFKA_SERVERS,
                                             value_serializer=pickle.dumps)

        redisPool.InitDB(10)
        mysqlPool.InitDB(20)
 def ListenEvent(self):
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(), "ServerChatEvent",
                         self, self.OnServerChat)
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(),
                         "OnScriptTickServer", self, self.OnServerTick)
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(),
                         "AddServerPlayerEvent", self, self.OnPlayerJoin)
     self.ListenForEvent(serverApi.GetEngineNamespace(),
                         serverApi.GetEngineSystemName(),
                         "DelServerPlayerEvent", self, self.OnPlayerExit)
     self.ListenForEvent(snakeGameFinalValuable.ModName,
                         snakeGameFinalValuable.ClientName,
                         snakeGameFinalValuable.OnKeyPress, self,
                         self.OnKeyPress)
Esempio n. 5
0
    def __init__(self, namespace, systemName):
        serverCls.__init__(self, namespace, systemName)
        self.timeTick = 0
        self.UpdateBool = False
        self.reSetNarratorPosBool = False
        self.sayBool = False
        self.saytimeTick = 0
        self.player = None
        self.narratorListId = [
            '-2190433320959', '-2190433320958', '-2190433320957',
            '-2190433320956', '-2190433320955', '-2190433320954',
            '-2190433320953', '-2190433320952', '-2190433320951',
            '-2190433320950'
        ]
        self.narratorListPosX = [29, 38, 55, 83, 95, 112, 136, 140, 115, 111]
        self.narratorListPosY = [66, 66, 66, 68, 67, 67, 66, 66, 67, 67]
        self.narratorListPosZ = [
            -136, -123, -129, -139, -112, -98, -135, -147, -120, -109
        ]

        # logger.info("<--MainServerSystem注册成功-->")
        self.ListenForEvent(serverApi.GetEngineNamespace(),
                            serverApi.GetEngineSystemName(),
                            "PlayerAttackEntityEvent", self,
                            self.PlayerAttackEntityEventHandler)
        self.ListenForEvent(serverApi.GetEngineNamespace(),
                            serverApi.GetEngineSystemName(),
                            "AddServerPlayerEvent", self,
                            self.AddServerPlayerEventHandler)
        self.ListenForEvent(serverApi.GetEngineNamespace(),
                            serverApi.GetEngineSystemName(), "ServerChatEvent",
                            self, self.ServerChatEventHandler)
        self.ListenForEvent("SXDtravlesMod", "answerUI", "ScoreEvent", self,
                            self.ScoreEventHandler)
        self.ListenForEvent("SXDtravlesMod", "dialogUI",
                            "attackExtraDataEvent", self,
                            self.attackExtraDataEventHandler)
        self.ListenForEvent("SXDtravlesMod", "ClientMain", "TeacherTextEvent",
                            self, self.TeacherTextEventHandler)
        self.ListenForEvent("SXDtravlesMod", "ClientMain", "progressEvent",
                            self, self.progressEventHandler)
        self.ListenForEvent("SXDtravlesMod", "ClientMain", "canAnswerEvent",
                            self, self.canAnswerEventHandler)
Esempio n. 6
0
    def Destroy(self):
        self.UnListenForEvent(serverApi.GetEngineNamespace(),
                              serverApi.GetEngineSystemName(),
                              'AddServerPlayerEvent', self,
                              self.connection_made)
        self.UnListenForEvent(serverApi.GetEngineNamespace(),
                              serverApi.GetEngineSystemName(),
                              'DelServerPlayerEvent', self,
                              self.connection_lost)
        self.UnListenForEvent(serverApi.GetEngineNamespace(),
                              serverApi.GetEngineSystemName(),
                              'LoadServerAddonScriptsAfter', self,
                              self.serve_forever)
        self.UnListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_CLI_NAME, 'G_DEBUT',
                              self, self.debut)
        self.UnListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_CLI_NAME, 'G_MATCH',
                              self, self.match)
        self.UnListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_CLI_NAME, 'G_COURT',
                              self, self.rcall)

        self._destroy()
 def UnListenEvent(self):
     self.UnListenForEvent(serverApi.GetEngineNamespace(), serverApi.GetEngineSystemName(), "ServerChatEvent", self, self.OnServerChat)
 def ListenEvent(self):
     # 在自定义的ServerSystem中监听引擎的事件ServerChatEvent,回调函数为OnServerChat
     self.ListenForEvent(serverApi.GetEngineNamespace(), serverApi.GetEngineSystemName(), "ServerChatEvent", self, self.OnServerChat)