spawn_protect.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:piqueserver 作者: piqueserver 项目源码 文件源码
def apply_script(protocol, connection, config):
    spawn_protect_time = config.get('spawn_protect_time', 3.0)

    class SpawnProtectConnection(connection):
        spawn_timestamp = None

        def on_spawn(self, pos):
            self.spawn_timestamp = reactor.seconds()
            return connection.on_spawn(self, pos)

        def on_hit(self, hit_amount, hit_player, type, grenade):
            cur_timestamp = reactor.seconds() - spawn_protect_time
            if cur_timestamp < hit_player.spawn_timestamp:
                timespan = -(cur_timestamp - hit_player.spawn_timestamp)
                self.send_chat(
                    "%s is spawn-protected for %s." %
                    (hit_player.name, prettify_timespan(
                        timespan, True)))
                return False
            return connection.on_hit(
                self, hit_amount, hit_player, type, grenade)
    return protocol, SpawnProtectConnection
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号