コード例 #1
0
ファイル: _commands.py プロジェクト: dazurn/minqlx
    def reply(self, msg):
        msg = str(msg)
        # Can deal with all the below ChatChannel subclasses.
        last_color = ""
        targets = None

        if isinstance(self, minqlx.TellChannel):
            cid = minqlx.Plugin.client_id(self.recipient)
            if cid == None:
                raise ValueError("Invalid recipient.")
            targets = [cid]
        elif self.team != "all":
            targets = []
            for p in minqlx.Player.all_players():
                if p.team == self.team:
                    targets.append(p.id)
        
        for s in self.split_long_msg(msg, limit=100):
            if not targets:
                minqlx.send_server_command(None, self.fmt.format(last_color + s))
            else:
                for cid in targets:
                    minqlx.send_server_command(cid, self.fmt.format(last_color + s))
            
            find = re_color_tag.findall(s)
            if find:
                last_color = find[-1]
コード例 #2
0
    def punish(self, player, pain=10, wait=0.5):
        @minqlx.next_frame
        def spec(_p):
            _p.put('spectator')

        @minqlx.next_frame
        def subtract_health(_p, _h):
            _p.health -= _h

        while self.game and self.game.state == 'in_progress' and player in self.punished:
            if not player.is_alive or player.health < pain:
                self.punished.remove(player)
                if self.put_to_spec: spec(player)
                break

            subtract_health(player, pain)
            if player.steam_id in self.positions:
                s = int((self.positions[player.steam_id])[1])
            else:
                s = self.detection
            message = "^1Inactive for {} seconds! \n\n^7Move or keep getting damage!".format(
                s)
            minqlx.send_server_command(player.id,
                                       "cp \"\n\n\n{}\"".format(message))
            time.sleep(wait)

        return
コード例 #3
0
ファイル: _plugin.py プロジェクト: PerpetualWar/minqlx
    def play_sound(cls, sound_path, player=None):
        if not sound_path or sound_path.startswith("music"):
            return False

        if player:
            minqlx.send_server_command(player.id, "playSound {}".format(sound_path))
        else:
            minqlx.send_server_command(None, "playSound {}".format(sound_path))
        return True
コード例 #4
0
ファイル: _plugin.py プロジェクト: carmethene/minqlx
    def play_sound(cls, sound_path, player=None):
        if not sound_path or "music/" in sound_path.lower():
            return False

        if player:
            minqlx.send_server_command(player.id, "playSound {}".format(sound_path))
        else:
            minqlx.send_server_command(None, "playSound {}".format(sound_path))
        return True
コード例 #5
0
    def play_sound(cls, sound_path: str, player: minqlx.Player = None) -> bool:
        if not sound_path or "music/" in sound_path.lower():
            return False

        if player:
            minqlx.send_server_command(player.id, f"playSound {sound_path}")
        else:
            minqlx.send_server_command(None, f"playSound {sound_path}")
        return True
コード例 #6
0
ファイル: _plugin.py プロジェクト: MinoMino/minqlx
    def play_sound(cls, sound_path, player=None):
        if not sound_path or "music/" in sound_path.lower():
            return False

        if player:
            minqlx.send_server_command(player.id, "playSound {}".format(sound_path))
        else:
            minqlx.send_server_command(None, "playSound {}".format(sound_path))
        return True
コード例 #7
0
ファイル: _plugin.py プロジェクト: MinoMino/minqlx
    def play_music(cls, music_path, player=None):
        if not music_path or "sound/" in music_path.lower():
            return False

        if player:
            minqlx.send_server_command(player.id, "playMusic {}".format(music_path))
        else:
            minqlx.send_server_command(None, "playMusic {}".format(music_path))
        return True
コード例 #8
0
ファイル: _plugin.py プロジェクト: carmethene/minqlx
    def play_music(cls, music_path, player=None):
        if not music_path or "sound/" in music_path.lower():
            return False

        if player:
            minqlx.send_server_command(player.id, "playMusic {}".format(music_path))
        else:
            minqlx.send_server_command(None, "playMusic {}".format(music_path))
        return True
コード例 #9
0
ファイル: _plugin.py プロジェクト: dazurn/minqlx
    def play_sound(cls, sound_path, player=None):
        if not sound_path or sound_path.startswith("music"):
            return False

        if player:
            minqlx.send_server_command(player.id,
                                       "playSound {}".format(sound_path))
        else:
            minqlx.send_server_command(None, "playSound {}".format(sound_path))
        return True
コード例 #10
0
    def center_print(
            cls,
            msg: str,
            recipient: Optional[Union[str, int,
                                      minqlx.Player]] = None) -> None:
        client_id: Optional[int] = None
        if recipient:
            client_id = cls.client_id(recipient)

        minqlx.send_server_command(client_id, f"cp \"{msg}\"")
コード例 #11
0
    def play_music(cls,
                   music_path: str,
                   player: Optional[minqlx.Player] = None) -> bool:
        if not music_path or "sound/" in music_path.lower():
            return False

        if player:
            minqlx.send_server_command(player.id, f"playMusic {music_path}")
        else:
            minqlx.send_server_command(None, f"playMusic {music_path}")
        return True
コード例 #12
0
ファイル: centerprint.py プロジェクト: Rayvor/minqlx-plugins
    def cmd_center_print(self, player, msg, channel):
        if len(msg) < 3:
            return minqlx.RET_USAGE

        target = self.find_by_name_or_id(player, msg[1])
        if not target:
            return minqlx.RET_STOP_ALL

        message = " ".join(msg[2:])
        minqlx.send_server_command(target.id, "cp \"\n\n\n{}\"".format(message))
        player.tell("^6Psst^7: succesfully printed '{}' on {}'s screen.".format(message, target.name))
        return minqlx.RET_STOP_ALL
コード例 #13
0
ファイル: centerprint.py プロジェクト: Rayvor/minqlx-plugins
    def handle_death(self, victim, killer, data):
        _vic = self.find_player(victim.name)[0]
        _vic_team = _vic.team

        if data['MOD'] == 'SWITCHTEAM':
            _vic_team == "red" if data['VICTIM']['TEAM'] == 2 else "blue"

        if self.game and self.game.state == 'in_progress':
            teams = self.teams()

            if int(data['TEAM_ALIVE']) == 1: # viewpoint of victim
                for _p in teams["red" if _vic_team == "blue" else "blue"]:
                    if self.get_notif_pref(_p.steam_id):
                        minqlx.send_server_command(_p.id, "cp \"\n\n\n{}!\"".format(self.get_cvar("qlx_cp_message")))
コード例 #14
0
   def mapRestart(self):
      @minqlx.next_frame # Game logic should never be done in a thread directly
      def game_logic(func): func()

      time.sleep(5)
      for x in range(5, -1, -1):
         if x == 0:
            minqlx.send_server_command(None, "cp \"map restarting...\"")
            continue

         minqlx.send_server_command(None, "cp \"map restarting in {}...\"".format(x))
         time.sleep(1)

      game_logic(lambda: minqlx.console_command('map_restart'))
コード例 #15
0
    def cmd_center_print(self, player, msg, channel):
        if len(msg) < 3:
            return minqlx.RET_USAGE

        target = self.find_by_name_or_id(player, msg[1])
        if not target:
            return minqlx.RET_STOP_ALL

        message = " ".join(msg[2:])
        minqlx.send_server_command(target.id,
                                   "cp \"\n\n\n{}\"".format(message))
        player.tell(
            "^6Psst^7: succesfully printed '{}' on {}'s screen.".format(
                message, target.name))
        return minqlx.RET_STOP_ALL
コード例 #16
0
    def handle_death(self, victim, killer, data):
        _vic = self.find_player(victim.name)[0]
        _vic_team = _vic.team

        if data['MOD'] == 'SWITCHTEAM':
            _vic_team == "red" if data['VICTIM']['TEAM'] == 2 else "blue"

        if self.game and self.game.state == 'in_progress':
            teams = self.teams()

            if int(data['TEAM_ALIVE']) == 1:  # viewpoint of victim
                for _p in teams["red" if _vic_team == "blue" else "blue"]:
                    if self.get_notif_pref(_p.steam_id):
                        minqlx.send_server_command(
                            _p.id, "cp \"\n\n\n{}!\"".format(
                                self.get_cvar("qlx_cp_message")))
コード例 #17
0
ファイル: afk.py プロジェクト: Rayvor/minqlx-plugins
 def punish(self, player, pain=10, wait=0.5):
     while self.game.state == 'in_progress' and player in self.punished:
         if player.health >= pain:
             player.health -= pain
             if player.steam_id in self.positions:
                 s = int((self.positions[player.steam_id])[1])
             else:
                 s = self.detection
             message = "^1Inactive for {} seconds! \n\n^7Move or keep getting damage!".format(s)
             minqlx.send_server_command(player.id, "cp \"\n\n\n{}\"".format(message))
             time.sleep(wait)
         else:
             break
     self.punished.remove(player)
     if self.put_to_spec: player.put('spectator')
     return
コード例 #18
0
ファイル: _commands.py プロジェクト: carmethene/minqlx
    def reply(self, msg, limit=100, delimiter=" "):
        # We convert whatever we got to a string and replace all double quotes
        # to single quotes, since the engine doesn't support escaping them.
        # TODO: rcon can print quotes to clients using NET_OutOfBandPrint. Maybe we should too?
        msg = str(msg).replace("\"", "'")
        # Can deal with all the below ChatChannel subclasses.
        last_color = ""
        targets = None

        if isinstance(self, minqlx.TellChannel):
            cid = minqlx.Plugin.client_id(self.recipient)
            if cid == None:
                raise ValueError("Invalid recipient.")
            targets = [cid]
        elif self.team != "all":
            targets = []
            for p in minqlx.Player.all_players():
                if p.team == self.team:
                    targets.append(p.id)

        split_msgs = self.split_long_lines(msg, limit, delimiter)
        # We've split messages, but we can still just join them up to 1000-ish
        # bytes before we need to send multiple server cmds.
        joined_msgs = []
        for s in split_msgs:
            if not len(joined_msgs):
                joined_msgs.append(s)
            else:
                s_new = joined_msgs[-1] + "\n" + s
                if len(s_new.encode(errors="replace")) > MAX_MSG_LENGTH:
                    joined_msgs.append(s)
                else:
                    joined_msgs[-1] = s_new

        for s in joined_msgs:
            if not targets:
                minqlx.send_server_command(None,
                                           self.fmt.format(last_color + s))
            else:
                for cid in targets:
                    minqlx.send_server_command(cid,
                                               self.fmt.format(last_color + s))

            find = re_color_tag.findall(s)
            if find:
                last_color = find[-1]
コード例 #19
0
ファイル: _commands.py プロジェクト: JoolsJealous/minqlx
    def reply(self, msg, limit=100, delimiter=" "):
        # We convert whatever we got to a string and replace all double quotes
        # to single quotes, since the engine doesn't support escaping them.
        # TODO: rcon can print quotes to clients using NET_OutOfBandPrint. Maybe we should too?
        msg = str(msg).replace("\"", "'")
        # Can deal with all the below ChatChannel subclasses.
        last_color = ""
        targets = None

        if isinstance(self, minqlx.TellChannel):
            cid = minqlx.Plugin.client_id(self.recipient)
            if cid == None:
                raise ValueError("Invalid recipient.")
            targets = [cid]
        elif self.team != "all":
            targets = []
            for p in minqlx.Player.all_players():
                if p.team == self.team:
                    targets.append(p.id)
        
        split_msgs = self.split_long_lines(msg, limit, delimiter)
        # We've split messages, but we can still just join them up to 1000-ish
        # bytes before we need to send multiple server cmds.
        joined_msgs = []
        for s in split_msgs:
            if not len(joined_msgs):
                joined_msgs.append(s)
            else:
                s_new = joined_msgs[-1] + "\n" + s
                if len(s_new.encode(errors="replace")) > MAX_MSG_LENGTH:
                    joined_msgs.append(s)
                else:
                    joined_msgs[-1] = s_new

        for s in joined_msgs:
            if not targets:
                minqlx.send_server_command(None, self.fmt.format(last_color + s))
            else:
                for cid in targets:
                    minqlx.send_server_command(cid, self.fmt.format(last_color + s))
            
            find = re_color_tag.findall(s)
            if find:
                last_color = find[-1]
コード例 #20
0
ファイル: afk.py プロジェクト: dsverdlo/minqlx-plugins
    def punish(self, player, pain=10, wait=0.5):
        @minqlx.next_frame
        def spec(_p): _p.put('spectator')
        @minqlx.next_frame
        def subtract_health(_p, _h): _p.health -= _h

        while self.game and self.game.state == 'in_progress' and player in self.punished:
            if not player.is_alive or player.health < pain:
                self.punished.remove(player)
                if self.put_to_spec: spec(player)
                break

            subtract_health(player, pain)
            if player.steam_id in self.positions:
                s = int((self.positions[player.steam_id])[1])
            else:
                s = self.detection
            message = "^1Inactive for {} seconds! \n\n^7Move or keep getting damage!".format(s)
            minqlx.send_server_command(player.id, "cp \"\n\n\n{}\"".format(message))
            time.sleep(wait)


        return
コード例 #21
0
ファイル: _plugin.py プロジェクト: zswin/minqlx
    def center_print(cls, msg, recipient=None):
        if recipient:
            recipient = cls.client_id(recipient)

        minqlx.send_server_command(recipient, "cp \"{}\"".format(msg))
コード例 #22
0
 def cmd_broadcast(self, player, msg, channel):
     for p in self.players():
         message = " ".join(msg[1:])
         minqlx.send_server_command(p.id, "cp \"\n\n\n{}\"".format(message))
     player.tell("^6Psst^7: Broadcast successful: '{}'".format(message))
コード例 #23
0
ファイル: _player.py プロジェクト: JoolsJealous/minqlx
 def center_print(self, msg):
     minqlx.send_server_command(self.id, "cp \"{}\"".format(msg))
コード例 #24
0
 def center_print(self, msg):
     minqlx.send_server_command(self.id, f"cp \"{msg}\"")
コード例 #25
0
ファイル: _plugin.py プロジェクト: MinoMino/minqlx
    def center_print(cls, msg, recipient=None):
        if recipient:
            recipient = cls.client_id(recipient)

        minqlx.send_server_command(recipient, "cp \"{}\"".format(msg))
コード例 #26
0
 def help_warn(self, player):
     message = "You have been inactive for {} seconds...".format(
         self.warning)
     minqlx.send_server_command(player.id,
                                "cp \"\n\n\n{}\"".format(message))
コード例 #27
0
ファイル: centerprint.py プロジェクト: Rayvor/minqlx-plugins
 def cmd_broadcast(self, player, msg, channel):
     for p in self.players():
         message = " ".join(msg[1:])
         minqlx.send_server_command(p.id, "cp \"\n\n\n{}\"".format(message))
     player.tell("^6Psst^7: Broadcast successful: '{}'".format(message))
コード例 #28
0
 def cmd_printfu(self, player, msg, channel):
     minqlx.send_server_command(None, "cp \"^0FUCK YOU\n^1FUCK YOU\n^2FUCK YOU\n^3FUCK YOU\n^4FUCK YOU\n^5FUCK YOU\n^6FUCK YOU\"\n")
コード例 #29
0
ファイル: _plugin.py プロジェクト: zswin/minqlx
 def stop_sound(cls, player=None):
     minqlx.send_server_command(player.id if player else None,
                                "clearSounds")
コード例 #30
0
ファイル: _plugin.py プロジェクト: zswin/minqlx
 def stop_music(cls, player=None):
     minqlx.send_server_command(player.id if player else None, "stopMusic")
コード例 #31
0
ファイル: _plugin.py プロジェクト: MinoMino/minqlx
 def stop_music(cls, player=None):
     minqlx.send_server_command(player.id if player else None, "stopMusic")
コード例 #32
0
 def center_print(self, player, message):
     if player in self.players():
         minqlx.send_server_command(player.id, "cp \"{}\"".format(message))
コード例 #33
0
 def set_player_configstring(self, player, index, key, value): # will let you set a configstring on a per-player basis.
     original_configstring = minqlx.parse_variables(minqlx.get_configstring(index))
     original_configstring[key] = value
     modified_configstring = (("\\") + ("\\".join("\\".join((k,str(v))) for k,v in sorted(original_configstring.items()))))
     minqlx.send_server_command(player.id, "cs {} {}".format(index, modified_configstring))
コード例 #34
0
ファイル: _player.py プロジェクト: zswin/minqlx
 def center_print(self, msg):
     minqlx.send_server_command(self.id, "cp \"{}\"".format(msg))
コード例 #35
0
 def stop_sound(cls, player: Optional[minqlx.Player] = None) -> None:
     minqlx.send_server_command(player.id if player else None,
                                "clearSounds")
コード例 #36
0
ファイル: _plugin.py プロジェクト: MinoMino/minqlx
 def stop_sound(cls, player=None):
     minqlx.send_server_command(player.id if player else None, "clearSounds")
コード例 #37
0
 def stop_music(cls, player: Optional[minqlx.Player] = None) -> None:
     minqlx.send_server_command(player.id if player else None, "stopMusic")
コード例 #38
0
 def center_print(self, player, message):
     if player in self.players():
         minqlx.send_server_command(player.id, "cp \"{}\"".format(message))
コード例 #39
0
ファイル: afk.py プロジェクト: dsverdlo/minqlx-plugins
 def help_warn(self, player):
     message = "You have been inactive for {} seconds...".format(self.warning)
     minqlx.send_server_command(player.id, "cp \"\n\n\n{}\"".format(message))