Пример #1
0
 def handle_vote_called(self, caller, vote, args):
     if vote.lower() == "dbalance":
         self.callvote("qlx !dbalance",
                       "Balance Teams based on database stored ELOs?")
         minqlx.client_command(caller.id, "vote yes")
         self.msg("{}^7 called a vote.".format(caller.name))
         return minqlx.RET_STOP_ALL
Пример #2
0
 def callvote_to_spec(self, caller, vote, player_name, player_id):
     try:
         self.callvote("put {} spec".format(player_id),
                       "Move {} to spectate?".format(player_name))
         minqlx.client_command(caller.id, "vote yes")
         self.msg("{}^7 called vote /cv {}".format(caller.name, vote))
         voter_perc = self.get_cvar("qlx_protectPlayerPercForVote", int)
         self.vote_count[0] = 1
         self.vote_count[1] = 0
         thread_number = random.randrange(1, 10000000)
         self.vote_count[2] = thread_number
         if voter_perc > 0:
             teams = self.teams()
             voters = len(teams["red"]) + len(teams["blue"])
             time.sleep(28.7)
             if self.vote_count[2] == thread_number and self.vote_count[0] / voters * 100 >= voter_perc and\
                     self.vote_count[0] > self.vote_count[1]:
                 self.force_vote(True)
         else:
             time.sleep(28.7)
             if self.vote_count[2] == thread_number and self.vote_count[
                     0] > self.vote_count[1]:
                 self.force_vote(True)
         self.vote_count[2] = 0
         return
     except Exception as e:
         minqlx.console_print(
             "^1protect.py callvote_to_spec Exception: {}".format([e]))
Пример #3
0
    def cmd_name(self, player, msg, channel):
        name_key = _name_key.format(player.steam_id)

        if len(msg) < 2:
            if name_key not in self.db:
                return minqlx.RET_USAGE
            else:
                del self.db[name_key]
                player.tell("Your registered name has been removed.")
                return minqlx.RET_STOP_EVENT

        name = self.clean_excessive_colors(" ".join(msg[1:]))
        if len(name.encode()) > 36:
            player.tell("The name is too long. Consider using fewer colors or a shorter name.")
            return minqlx.RET_STOP_EVENT
        elif self.clean_text(name) != player.clean_name and self.get_cvar("qlx_enforceSteamName", bool):
            player.tell("The colored name must match your current Steam name.")
            return minqlx.RET_STOP_EVENT

        info = minqlx.parse_variables(minqlx.player_info(player.id)["userinfo"], ordered=True)
        info["name"] = name
        new_info = "".join(["\\{}\\{}".format(key, info[key]) for key in info])
        minqlx.client_command(player.id, 'userinfo "{}"'.format(new_info))
        self.db[name_key] = name
        player.tell(
            "The name has been registered. To make me forget about it, a simple ^6{}name^7 will do it.".format(
                self.get_cvar("qlx_commandPrefix")
            )
        )
        return minqlx.RET_STOP_EVENT
Пример #4
0
 def handle_vote_called(self, caller, vote, args):
     # Global Voice Chat Vote
     if vote.lower() == "globalvoice" or vote.lower(
     ) == "globalchat" or vote.lower() == "gvoice" or vote.lower(
     ) == "gchat":
         if not self.get_cvar("qlx_voicechatVoiceChatVoting", bool):
             caller.tell(
                 "^3Voting for global voice chatting is not enabled on this server."
             )
             return minqlx.RET_STOP_ALL
         self.callvote("set g_alltalk 1", "Set voice chatting to GLOBAL?")
         minqlx.client_command(caller.id, "vote yes")
         self.msg("{}^7 called a vote.".format(caller.name))
         return minqlx.RET_STOP_ALL
     # Team Voice Chat Vote
     if vote.lower() == "teamvoice" or vote.lower(
     ) == "teamchat" or vote.lower() == "tvoice" or vote.lower() == "tchat":
         if not self.get_cvar("qlx_voicechatVoiceChatVoting", bool):
             caller.tell(
                 "^3Voting for team voice chatting is not enabled on this server."
             )
             return minqlx.RET_STOP_ALL
         self.callvote("set g_alltalk 0",
                       "Set voice chatting to TEAM ONLY?")
         minqlx.client_command(caller.id, "vote yes")
         self.msg("{}^7 called a vote.".format(caller.name))
         return minqlx.RET_STOP_ALL
Пример #5
0
 def force_switch_vote(self, caller, vote):
     try:
         self.callvote(
             "qlx {}force_agree".format(self.get_cvar("qlx_commandPrefix")),
             "Force the suggested player switch?")
         minqlx.client_command(caller.id, "vote yes")
         self.msg("{}^7 called vote /cv {}".format(caller.name, vote))
         voter_perc = self.get_cvar("qlx_balanceDoVotePerc", int)
         self.vote_active = True
         self.vote_count[0] = 1
         self.vote_count[1] = 0
         self.vote_count[2] = thread_number = random.randrange(0, 10000000)
         teams = self.teams()
         if voter_perc > 0:
             voters = len(teams["red"]) + len(teams["blue"])
             time.sleep(28.7)
             if self.vote_active and self.vote_count[2] == thread_number and\
                     self.vote_count[0] / voters * 100 >= voter_perc and self.vote_count[0] > self.vote_count[1]:
                 self.force_vote(True)
                 self.vote_active = False
         else:
             time.sleep(28.7)
             if self.vote_active and self.vote_count[
                     2] == thread_number and self.vote_count[
                         0] > self.vote_count[1]:
                 self.force_vote(True)
                 self.vote_active = False
         return
     except Exception as e:
         minqlx.console_print(
             "^1doVote check_force_switch_vote Exception: {}".format(e))
Пример #6
0
    def check_and_spec(self, player):
        player_spec_setting = self.db.get(
            PLAYER_KEY.format(player.steam_id) + ":qltv")

        if player_spec_setting:
            if int(player_spec_setting) == 1 and self.sorted_players:
                minqlx.client_command(
                    player.id, 'follow ' + str(self.sorted_players[0].id))
Пример #7
0
 def handle_player_loaded(self, player):
     name_key = _name_key.format(player.steam_id)
     if name_key in self.db:
         db_name = self.db[name_key]
         if not self.get_cvar("qlx_enforceSteamName", bool) or self.clean_text(db_name) == player.clean_name:
             info = minqlx.parse_variables(minqlx.player_info(player.id)["userinfo"], ordered=True)
             info["name"] = db_name
             new_info = "".join(["\\{}\\{}".format(key, info[key]) for key in info])
             minqlx.client_command(player.id, 'userinfo "{}"'.format(new_info))
Пример #8
0
    def handle_vote_called(self, caller, vote, args):
        if not self.get_cvar("g_allowSpecVote", bool) and caller.team == "spectator":
            caller.tell("You are not allowed to call a vote as spectator.")
            return minqlx.RET_NONE

        if minqlx.Plugin.is_vote_active():
            return minqlx.RET_NONE

        if vote.lower() == "thrufloors":
            if args.lower() == "off":
                minqlx.callvote("g_forceDmgThroughSurface 0", "Turn off damage through floors?")
                minqlx.client_command(caller.id, "vote yes")
                self.msg(f"{caller.name}^7 called a vote.")
                return minqlx.RET_STOP_ALL
            if args.lower() == "on":
                minqlx.callvote("g_forceDmgThroughSurface 1", "Turn on damage through floors?")
                minqlx.client_command(caller.id, "vote yes")
                self.msg(f"{caller.name}^7 called a vote.")
                return minqlx.RET_STOP_ALL
            caller.tell("^2/cv thrufloors [on/off]^7 is the usage for this callvote command.")
            return minqlx.RET_STOP_ALL

        if vote.lower() == "spec":
            target_player = self.find_target_player_or_list_alternatives(caller, args)
            if target_player is None:
                return minqlx.RET_STOP_ALL

            if target_player.team == "spectator":
                caller.tell(f"Player {target_player.name}^7 is already in the spectators.")
                return minqlx.RET_STOP_ALL

            minqlx.callvote(f"put {target_player.id} spec", f"spec {target_player.name}^7?")
            minqlx.client_command(caller.id, "vote yes")
            self.msg(f"{caller.name}^7 called a vote.")
            return minqlx.RET_STOP_ALL

        if vote.lower() == "mute":
            target_player = self.find_target_player_or_list_alternatives(caller, args)
            if target_player is None:
                return minqlx.RET_STOP_ALL

            minqlx.callvote(
                f"qlx !silence {target_player.id} 10 minutes You were call-voted silent for 10 minutes.;"
                f"mute {target_player.id}", f"Mute {target_player.name}^7 for 10 minutes?")
            minqlx.client_command(caller.id, "vote yes")
            self.msg(f"{caller.name}^7 called a vote.")
            return minqlx.RET_STOP_ALL

        if vote.lower() == "allready":
            if self.game.state == "warmup":
                minqlx.callvote("qlx !allready", "Ready all players?")
                minqlx.client_command(caller.id, "vote yes")
                return minqlx.RET_STOP_ALL
            caller.tell("The game is already in progress.")
            return minqlx.RET_STOP_ALL

        return minqlx.RET_NONE
    def handle_vote_called(self, caller, vote, args):
        if vote.lower() != "mode":
            return minqlx.RET_NONE

        if args.lower() not in self.available_modes():
            return minqlx.RET_NONE

        if args.lower() == self.mode.lower():
            return minqlx.RET_STOP_ALL

        Plugin.callvote(f"mode {args.lower()}", f"mode {args.lower()}")
        minqlx.client_command(caller.id, "vote yes")

        self.msg(f"{caller.name}^7 called a vote.")
        return minqlx.RET_STOP_ALL
    def cmd_teamsize(self, player, msg, channel): # let the player use !ts if they want to, but call a vote instead.
        if len(msg) < 2:
            return minqlx.RET_USAGE

        if self.db.has_permission(player, 2):
            return
       
        try:
            new_ts = int(msg[1])
        except ValueError:
            channel.reply("^7Unintelligible size.")
            return

        player.tell("Calling a teamsize vote for you.")
        minqlx.client_command(player.id, "callvote teamsize {}".format(new_ts))
        return minqlx.RET_STOP_ALL
Пример #11
0
 def handle_vote_called(self, caller, vote, args):
     # Global Voice Chat Vote
     if vote.lower() == "globalvoice" or vote.lower() == "globalchat" or vote.lower() == "gvoice" or vote.lower() == "gchat":
         if not self.get_cvar("qlx_voicechatVoiceChatVoting", bool):
             caller.tell("^3Voting for global voice chatting is not enabled on this server.")
             return minqlx.RET_STOP_ALL
         self.callvote("set g_alltalk 1", "Set voice chatting to GLOBAL?")
         minqlx.client_command(caller.id, "vote yes")
         self.msg("{}^7 called a vote.".format(caller.name))
         return minqlx.RET_STOP_ALL
     # Team Voice Chat Vote
     if vote.lower() == "teamvoice" or vote.lower() == "teamchat" or vote.lower() == "tvoice" or vote.lower() == "tchat":
         if not self.get_cvar("qlx_voicechatVoiceChatVoting", bool):
             caller.tell("^3Voting for team voice chatting is not enabled on this server.")
             return minqlx.RET_STOP_ALL
         self.callvote("set g_alltalk 0", "Set voice chatting to TEAM ONLY?")
         minqlx.client_command(caller.id, "vote yes")
         self.msg("{}^7 called a vote.".format(caller.name))
         return minqlx.RET_STOP_ALL
Пример #12
0
 def cvars(self, new_cvars):
     new = "".join([f"\\{key}\\{new_cvars[key]}" for key in new_cvars])
     minqlx.client_command(self.id, f"userinfo \"{new}\"")
Пример #13
0
 def cmd_random_map(self, player, msg, channel):
     """Callvotes a random map."""
     map_name = random.choice(self.maps)
     minqlx.client_command(player.id, "cv map {}".format(map_name))
Пример #14
0
 def repeat_command():
     minqlx.client_command(player.id, cmd)
Пример #15
0
 def cvars(self, new_cvars):
     new = "".join(["\\{}\\{}".format(key, new_cvars[key]) for key in new_cvars])
     minqlx.client_command(self.id, "userinfo \"{}\"".format(new))
Пример #16
0
    def handle_client_command(self, player, cmd):

        # 명령어 중복 해석을 막음. 수행시간은 정상적인 경우 O(1)
        if cmd in self.cmdbuffer[player.id]:
            self.cmdbuffer[player.id].remove(cmd)
            return

        trigger = self.get_cvar("qlx_KrIME_Trigger")

        if self.get_cvar("qlx_KrIME_ClientTrigger") == 0 or trigger == "":
            return

        cmdpattern = re.compile("say\s+|say_team\s+", re.IGNORECASE)
        matchresult = cmdpattern.match(cmd)

        if matchresult is None:
            return
        else:

            cmdhead = matchresult.group(0)
            text = cmdpattern.sub("", cmd, 1)
            text = text.rstrip()
            if text.startswith('"') and text.endswith('"'):
                text = text[1:-1]
            elif text.startswith("'") and text.endswith("'"):
                text = text[1:-1]

            triggerpattern = re.compile(trigger)
            triggermatchresult = triggerpattern.match(text)

            if triggermatchresult is None:
                return
            else:
                text = triggerpattern.sub("", text, 1)

            encodestatus = ENCODE_EMPTY
            first = ""
            second = ""
            last = ""
            resulttext = ""
            rtlength = 0

            for c in text:
                temp = copy.deepcopy(c)

                if encodestatus == ENCODE_EMPTY:

                    # 초성 중성 종성 아무 것도 없다.
                    # 한 글자가 입력될 경우 자모는 모두 초성이거나 중성이어야 한다.
                    if getFirstSyllabelIndex(temp) != -1:
                        first = temp
                        encodestatus = ENCODE_FIRST

                    elif getSecondSyllabelIndex(temp) != -1:
                        second = temp
                        encodestatus = ENCODE_SECOND

                    else:
                        if rtlength + 1 < CHAT_MAXLENGTH:
                            resulttext += temp


                elif encodestatus == ENCODE_FIRST:

                    # 초성이 1개 입력되었으므로 앞으로의 가능성은 다른 초성이 들어오고 그것이 현재 있는
                    # 초성과 합쳐지는 것이 가능해 종성으로 변하는 경우
                    # 다른 중성이 들어와 그것이 현재 있는 초성에 이어지는 경우
                    # 그 이외의 문자가 들어와 조합이 중단될 경우
                    if getFirstSyllabelIndex(temp) != -1:

                        temp2 = first + temp
                        if getLastSyllabelIndex(temp2) != -1:
                            first = ""
                            last = temp2
                            encodestatus = ENCODE_LAST
                        else:
                            if rtlength + 3 < CHAT_MAXLENGTH:
                                resulttext += encodecharacter(first, second, last)
                            first = temp
                            encodestatus = ENCODE_FIRST
                    elif getSecondSyllabelIndex(temp) != -1:

                        second = temp
                        encodestatus = ENCODE_SECOND
                    else:
                        # 초성이 입력된 상태로 한글이 아닌 다른 문자가 들어왔다. 완성된 글자를 내보낸다.

                        if rtlength + 3 < CHAT_MAXLENGTH:
                            resulttext += encodecharacter(first, second, last)
                        first = ""
                        encodestatus = ENCODE_EMPTY
                        resulttext += temp

                elif encodestatus == ENCODE_SECOND:

                    # 초성과 중성이 모두 있거나, 중성만 있다.
                    if getLastSyllabelIndex(temp) != -1:

                        # 종성을 받아들일 수 있다.
                        if first != "":
                            last = temp
                            encodestatus = ENCODE_LAST
                        else:  # 초성없이 종성이 되는 초성을 받은 상태. 현재 글자를 내보낸다.
                            if rtlength + 3 < CHAT_MAXLENGTH:
                                resulttext += encodecharacter(first, second, last)
                            first = temp
                            second = ""
                            last = ""
                            encodestatus = ENCODE_FIRST

                    elif getFirstSyllabelIndex(temp) != -1:

                        # 종성이 될 수 없는 초성 입력이 들어왔다. 이것이 가능한가?
                        if rtlength + 3 < CHAT_MAXLENGTH:
                            resulttext += encodecharacter(first, second, last)
                        first = temp
                        second = ""
                        last = ""
                        encodestatus = ENCODE_FIRST

                    elif getSecondSyllabelIndex(temp) != -1:

                        if len(second) == 2:
                            # 중성이 들어왔지만 받아들일 수 없으므로 내보낸다.
                            if rtlength + 3 < CHAT_MAXLENGTH:
                                resulttext += encodecharacter(first, second, last)
                            first = ""
                            second = temp
                        else:
                            temp2 = second + temp
                            if getSecondSyllabelIndex(temp2) != -1:
                                second += temp
                            else:
                                if rtlength + 3 < CHAT_MAXLENGTH:
                                    resulttext += encodecharacter(first, second, last)
                                first = ""
                                second = temp

                    else:
                        # 중성이 입력된 상태로 한글이 아닌 다른 문자가 들어왔다. 완성된 글자를 내보낸다.
                        if rtlength + 3 < CHAT_MAXLENGTH:
                            resulttext += encodecharacter(first, second, last)
                        first = ""
                        second = ""
                        last = ""
                        encodestatus = ENCODE_EMPTY
                        if rtlength + 1 < CHAT_MAXLENGTH:
                            resulttext += temp

                elif encodestatus == ENCODE_LAST:

                    # 초성, 중성, 종성이 모두 있거나 종성만 있는 상태

                    # 종성이 온다면 기존 종성과 조합 가능한지 확인
                    if getLastSyllabelIndex(temp) != -1:

                        if len(last) == 2:  # 종성이 이미 2개인 상태
                            if rtlength + 3 < CHAT_MAXLENGTH:
                                resulttext += encodecharacter(first, second, last)
                            first = temp
                            second = ""
                            last = ""
                            encodestatus = ENCODE_FIRST

                        else:

                            temp2 = last + temp

                            if getLastSyllabelIndex(temp2) != -1:

                                last = temp2

                            else:  # 종성이 이미 있는데 조합될 수 없는 종성이 왔다.

                                if rtlength + 3 < CHAT_MAXLENGTH:
                                    resulttext += encodecharacter(first, second, last)
                                first = temp  # 모든 단일 종성은 초성이 될 수 있다.
                                second = ""
                                last = ""
                                encodestatus = ENCODE_FIRST

                    elif getFirstSyllabelIndex(temp) != -1:

                        # 종성까지 입력되었는데 초성이 왔다.
                        if rtlength + 3 < CHAT_MAXLENGTH:
                            resulttext += encodecharacter(first, second, last)
                        first = temp
                        second = ""
                        last = ""
                        encodestatus = ENCODE_FIRST

                    elif getSecondSyllabelIndex(temp) != -1:

                        temp2 = ""
                        if len(last) == 2:  # 종성이 있을 때 중성이 입력될 경우 종성을 다음 중성에 떼어주고 자신은 완성된다.
                            temp2 = copy.deepcopy(last[1])
                            last = last[0]
                        else:
                            temp2 = copy.deepcopy(last)
                            last = ""

                        if rtlength + 3 < CHAT_MAXLENGTH:
                            resulttext += encodecharacter(first, second, last)
                        first = temp2
                        second = temp
                        last = ""
                        encodestatus = ENCODE_SECOND

                    else:

                        # 한글 자모가 아닌 문자가 들어왔다.
                        if rtlength + 3 < CHAT_MAXLENGTH:
                            resulttext += encodecharacter(first, second, last)
                        first = ""
                        second = ""
                        last = ""
                        encodestatus = ENCODE_EMPTY
                        if rtlength + 1 < CHAT_MAXLENGTH:
                            resulttext += temp

            # 남은 문자를 기록한다.
            if rtlength + 3 < CHAT_MAXLENGTH:
                resulttext += encodecharacter(first, second, last)

            self.cmdbuffer[player.id].append(cmdhead + resulttext)
            minqlx.client_command(player.id, cmdhead + resulttext)


        return minqlx.RET_STOP_ALL
    def handle_vote_called(self, caller, vote, args):            
        if vote.lower() == "map":
            # prevent map votes during an in-progress match (credit: baest)
            if (self.game.state == "in_progress") and (self.game.type_short == "ca"):
                caller.tell("Voting to change the map after the match has started is disabled on this server.")
                return minqlx.RET_STOP_ALL
            
            # prevent certain maps from being loaded, if they're found to have issues
            if args.lower() is "disabled_test" or args.lower() in self.disabled_maps:
                caller.tell("Map ^4{}^7 is currently disabled, please contact an admin/mod for details.".format(args.lower()))
                return minqlx.RET_STOP_ALL

            # exception for maido map
            if args.lower() in "maido":
                voteFlags = self.get_cvar("g_voteFlags")
                self.set_cvar("g_voteFlags", "0")

                if self.game.type_short != "duel": return 
                
                @minqlx.next_frame
                def f(theFlags):
                    minqlx.client_command(caller.id, "callvote map maido maido")
                    self.set_cvar("g_voteFlags", theFlags)
                f(voteFlags)

                return minqlx.RET_STOP_ALL

            if args.lower() == "rustcampgrounds":
                minqlx.client_command(caller.id, "callvote map oxodm102_b1")
                caller.tell("Resolved ^4rustcampgrounds^7 to ^4oxodm102_b1^7.")
                return minqlx.RET_STOP_ALL

        if (vote.lower() == "kick") or (vote.lower() == "clientkick"):
            if len(args.split()) < 1:
                return minqlx.RET_STOP
            
            for steam_id in self.protectedPlayers:
                try:
                    if vote.lower() == "kick":
                        kickee = self.find_player(args.lower())[0]
                    elif vote.lower() == "clientkick":
                        kickee = self.player(int(args))
                        
                    if str(kickee.steam_id) == str(minqlx.owner()):
                        caller.tell("{}^7 is the server owner and cannot be kicked. {}^7 has been notified.".format(kickee.name, kickee.name))
                        kickee.tell("{}^7 just tried to call a {} vote against you.".format(caller.name, vote.lower()))
                        return minqlx.RET_STOP_ALL
                except:
                    return minqlx.RET_STOP
                    
                if str(steam_id) == str(kickee.steam_id):
                    caller.tell("{}^7 is in the list of protected players and cannot be kicked.".format(kickee.name))
                    return minqlx.RET_STOP_ALL

        if vote.lower() == "teamsize":
            if len(args.split()) < 1:
                return minqlx.RET_STOP

            if self.get_cvar("teamsize", str) in str(args):
                caller.tell("You sir, need to open your eyes. Only then will you see that the teamsize is already set to {}.".format(self.get_cvar("teamsize")))
                return minqlx.RET_STOP_ALL

        if vote.lower() == "autobot":
            # enables the '/cv autobot [on/off]' command
            if args.lower() == "off":
                self.callvote("set bot_autoManage 0", "automatic bot management: off")
                self.msg("{}^7 called a vote.".format(caller.name))
                return minqlx.RET_STOP_ALL
            elif args.lower() == "on":
                self.callvote("set bot_autoManage 1", "automatic bot management: on")
                self.msg("{}^7 called a vote.".format(caller.name))
                return minqlx.RET_STOP_ALL
            else:
                caller.tell("^2/cv autobot [on/off]^7 is the usage for this callvote command.")
                return minqlx.RET_STOP_ALL

        if vote.lower() == "gibs":
            # enables the '/cv gibs [on/off]' command
            if args.lower() == "off":
                self.callvote("clearcvar qlx_workshopReferences", "^1gibs^3: off")
                self.msg("{}^7 called a vote.".format(caller.name))
                return minqlx.RET_STOP_ALL
            elif args.lower() == "on":
                self.callvote("set qlx_workshopReferences 691078677", "^1gibs^3: on")
                self.msg("{}^7 called a vote.".format(caller.name))
                return minqlx.RET_STOP_ALL
            else:
                caller.tell("^2/cv gibs [on/off]^7 is the usage for this callvote command.")
                return minqlx.RET_STOP_ALL

        if vote.lower() == "draw":
            if self.game.state != "in_progress":
                caller.tell("Voting to draw the round during warm-up isn't possible.")
                return minqlx.RET_STOP_ALL
            else:
                self.callvote("qlx !killall", "round draw")
                self.msg("{}^7 called a vote.".format(caller.name))
                return minqlx.RET_STOP_ALL

        if vote.lower() == "do":
            if "balance" in self.plugins:
                if self.plugins["balance"].suggested_pair:
                    self.callvote("qlx !do", "force the suggested switch")
                    self.msg("{}^7 called a vote.".format(caller.name))
                else:
                    caller.tell("A switch hasn't been suggested yet by ^4!teams^7, you cannot vote to apply a suggestion that doesn't exist.")
            else:
                caller.tell("The ^4balance^7 system isn't currently loaded. This vote cannot function.")
                
            return minqlx.RET_STOP_ALL
Пример #18
0
 def cvars(self, new_cvars):
     new = "".join(["\\{}\\{}".format(key, new_cvars[key]) for key in new_cvars])
     minqlx.client_command(self.id, "userinfo \"{}\"".format(new))
 def f(theFlags):
     minqlx.client_command(caller.id, "callvote map maido maido")
     self.set_cvar("g_voteFlags", theFlags)
Пример #20
0
 def cmd_hello(self, player, msg, channel):
     for p in self.players():
         minqlx.client_command(player.id, "say Hello {}^2".format(self.clean_name(p.name)))
         time.sleep(0.1)
Пример #21
0
 def name(self, value):
     info = minqlx.parse_variables(minqlx.get_userinfo(self.id), ordered=True)
     info["name"] = value
     new_info = "\\".join(["{}\\{}".format(key, info[key]) for key in info])
     minqlx.client_command(self.id, "userinfo \"{}\"".format(new_info))
     self._name = value
Пример #22
0
 def repeat_command():
     minqlx.client_command(player.id, cmd)
Пример #23
0
 def cmd_elated_emoji(self, player, msg, channel):
     num1 = randint(0,6)
     num2 = randint(0,6)
     minqlx.client_command(player.id, "say ^{}:^{}D".format(num1, num2))
     return minqlx.RET_STOP_ALL
Пример #24
0
 def name(self, value):
     info = minqlx.parse_variables(minqlx.get_userinfo(self.id), ordered=True)
     info["name"] = value
     new_info = "\\".join(["{}\\{}".format(key, info[key]) for key in info])
     minqlx.client_command(self.id, 'userinfo "{}"'.format(new_info))
     self._name = value
Пример #25
0
    def handle_vote_called(self, caller, vote, args):
        # Map Voting
        vote = vote.lower()
        if (vote == "map" or vote == "nextmap" or vote == "map_restart"
            ) and self.mapProtect and self.game.state == "in_progress":
            caller.tell("^3Map voting is not allowed during an active match")
            return minqlx.RET_STOP_ALL
        # Kick Voting
        elif vote == "kick" or vote == "clientkick":
            try:
                client_id = int(args)
                target_player = self.player(client_id)
            except ValueError:
                target_player = self.player(args)
            ident = target_player.steam_id
            perm = self.db.get_permission(ident)
            if ident == minqlx.owner():
                caller.tell("^2That's my master! I won't let this vote pass.")
                return minqlx.RET_STOP_ALL
            elif int(perm) >= int(self.protectPermission):
                caller.tell(
                    "^2That player is too important on this server and can't be kicked."
                )
                return minqlx.RET_STOP_ALL
            elif ident in self.protect:
                caller.tell("^3That player is in the ^1kick protect^3 list.")
                return minqlx.RET_STOP_ALL
        # Voting people to Spectator
        elif vote == "afk" or vote == "spectate":
            if not self.get_cvar("qlx_protectAfkVoting", bool):
                caller.tell(
                    "^3Voting players to spectator is not enabled on this server."
                )
                return minqlx.RET_STOP_ALL
            try:
                player_name = self.player(int(args)).clean_name
                player_id = self.player(int(args)).id
            except:
                caller.tell(
                    "^1Invalid ID.^7 Use a client ID from the ^2/players^7 command."
                )
                return minqlx.RET_STOP_ALL

            if self.player(int(args)).team == "spectator":
                caller.tell("That player is already in the spectators.")
                return minqlx.RET_STOP_ALL
            self.callvote("put {} spec".format(player_id),
                          "Move {} to spectate?".format(player_name))
            minqlx.client_command(caller.id, "vote yes")
            self.msg("{}^7 called a vote.".format(caller.name))
            return minqlx.RET_STOP_ALL
        # Voting to mute people
        elif vote == "mute" or vote == "silence":
            if not self.get_cvar("qlx_protectMuteVoting", bool):
                caller.tell(
                    "^3Voting to mute players is not enabled on this server.")
                return minqlx.RET_STOP_ALL
            try:
                player_name = self.player(int(args)).clean_name
                player_id = self.player(int(args)).id
            except:
                caller.tell(
                    "^1Invalid ID.^7 Use a client ID from the ^2/players^7 command."
                )
                return minqlx.RET_STOP_ALL
            ident = self.player(int(args)).steam_id
            perm = self.db.get_permission(ident)
            if ident == minqlx.owner():
                caller.tell("^2That's my master! I won't let this vote pass.")
                return minqlx.RET_STOP_ALL
            elif int(perm) >= int(self.protectPermission):
                caller.tell(
                    "^2That player is too important on this server and can't be muted."
                )
                return minqlx.RET_STOP_ALL
            self.callvote("mute {}".format(player_id),
                          "Mute {}?".format(player_name))
            minqlx.client_command(caller.id, "vote yes")
            self.msg("{}^7 called a vote.".format(caller.name))
            return minqlx.RET_STOP_ALL
        # Voting to unMute people
        elif vote == "unmute" or vote == "unsilence":
            if not self.get_cvar("qlx_protectMuteVoting", bool):
                caller.tell(
                    "^3Voting to mute/unmute players is not enabled on this server."
                )
                return minqlx.RET_STOP_ALL
            try:
                player_name = self.player(int(args)).clean_name
                player_id = self.player(int(args)).id
            except:
                caller.tell(
                    "^1Invalid ID.^7 Use a client ID from the ^2/players^7 command."
                )
                return minqlx.RET_STOP_ALL
            if int(caller.id) == int(player_id):
                caller.tell("^3Sorry, you cannot callvote to unmute yourself.")
                return minqlx.RET_STOP_ALL
            self.callvote("unmute {}".format(player_id),
                          "UnMute {}?".format(player_name))
            minqlx.client_command(caller.id, "vote yes")
            self.msg("{}^7 called a vote.".format(caller.name))
            return minqlx.RET_STOP_ALL
Пример #26
0
    def handle_vote_called(self, caller, vote, args):
        if caller.id in self.vote_banned:
            caller.tell(
                "^1You have had your voting privileges removed by a server callvote."
                " Your vote will not be allowed.")
            minqlx.console_print(
                "^3Player ^6{} ^7tried calling a vote while on the votelimiter voteban list."
                " Vote was denied.".format(caller))
            return minqlx.RET_STOP_ALL

        vote = vote.lower()
        sid = caller.steam_id

        if vote == "voteban":
            try:
                player = self.player(int(args))
                player_id = player.id
            except ValueError:
                player, player_id = self.find_player(args)
                if player_id == -1:
                    if player == 0:
                        caller.tell(
                            "^1Too Many players matched your player name")
                    else:
                        caller.tell("^1No player matching that name found")
                    return minqlx.RET_STOP_ALL
            except Exception as e:
                if type(e).__name__ == "NonexistentPlayerError":
                    caller.tell(
                        "^1Invalid ID.^7 Use a client ID from the ^2/players^7 command."
                    )
                    return minqlx.RET_STOP_ALL
                minqlx.console_print(
                    "^3Exception during vote call attempt^7: ^1{} ^7: ^4{}".
                    format(type(e).__name__, e.args))
                return minqlx.RET_STOP_ALL

            if self.db.get_permission(player) >= self.AdminLevel and\
                    self.db.get_permission(player) >= self.db.get_permission(caller):
                caller.tell(
                    "^3That player is a server admin and can't have their voting privileges suspended."
                )
                minqlx.console_print(
                    "Votelimiter voteban attempted for player {}."
                    " Vote denied due to admin permission level.".format(
                        player))
                return minqlx.RET_STOP_ALL

            self.callvote(
                "qlx {}votelimiter_voteban {}".format(
                    self.get_cvar("qlx_commandPrefix"), player_id),
                "Ban {} from calling votes on the server?".format(player))
            minqlx.client_command(caller.id, "vote yes")
            self.msg("{}^7 called vote /cv {} {}".format(
                caller.name, vote, args))
            return minqlx.RET_STOP_ALL

        if self.get_cvar("qlx_voteLimiterTypes",
                         bool) and vote not in self.voteLimiterAllowed:
            minqlx.console_print(
                "{} called vote {} {}, which is currently disabled on the server."
                .format(caller, vote, args))
            caller.tell(
                "^3That vote type is not allowed on this server.\nSpeak to a server admin if this is in error"
            )
            return minqlx.RET_STOP_ALL

        if self.get_cvar(
                "qlx_voteLimiterExcludeAdmin",
                bool) and self.db.get_permission(caller) >= self.AdminLevel:
            return

        if sid not in self.voteLimiterVote:
            self.voteLimiterVote[sid] = {}

        if vote not in self.voteLimiterVote[sid]:
            self.voteLimiterVote[sid]["{}".format(vote)] = vote
            self.voteLimiterVote[sid]["{}_time".format(vote)] = int(
                time.time())
            self.voteLimiterVote[sid]["{}_count".format(vote)] = 0

        elapsed = int(
            time.time()) - self.voteLimiterVote[sid]["{}_time".format(vote)]
        delay = self.get_cvar("qlx_voteLimiterDelay", int)

        if sid in self.voteLimiterCount:
            self.voteLimiterCount[sid] += 1
            if self.voteLimiterCount[sid] >= self.get_cvar(
                    "qlx_voteLimiterLimit", int):
                caller.tell(
                    "^3You have called your maximum number of votes.\n"
                    "^3Your vote count will reset at the end of a game/match.")
                return minqlx.RET_STOP_ALL
        else:
            self.voteLimiterCount[sid] = 1

        if self.get_cvar(
                "qlx_voteLimiterAllowed",
                int) > self.voteLimiterVote[sid]["{}_count".format(vote)]:
            self.voteLimiterVote[sid]["{}_count".format(vote)] += 1
        elif elapsed <= delay:
            caller.tell(
                "^3You have called a {} type of vote, ^2{} seconds ^3before you "
                "can call this type of vote again.".format(
                    vote, delay - elapsed))
            return minqlx.RET_STOP_ALL
        self.steam_id = sid
        self.voteLimiterVote[sid]["{}_time".format(vote)] = int(time.time())