Ejemplo n.º 1
0
    def cmd_goto(self, player, msg, channel):
        """Go to a player's location.
        Player needs to kill themselves/rejoin for a time to count."""
        map_name = self.game.map.lower()
        if map_name in GOTO_DISABLED:
            player.tell("^1!goto is disabled on {}".format(map_name))
            return minqlx.RET_STOP_ALL

        if len(msg) == 2:
            try:
                i = int(msg[1])
                target_player = self.player(i)
                if not (0 <= i < 64) or not target_player or not self.player(i).is_alive or i == player.id:
                    raise ValueError
            except ValueError:
                player.tell("Invalid ID.")
                return minqlx.RET_STOP_ALL
            except minqlx.NonexistentPlayerError:
                player.tell("Invalid ID.")
                return minqlx.RET_STOP_ALL
        elif len(msg) != 2:
            return minqlx.RET_USAGE

        if player.team == "spectator":
            if 'spec_delay' in self.plugins and player.steam_id in self.plugins['spec_delay'].spec_delays:
                player.tell("^6You must wait 15 seconds before joining after spectating")
                return minqlx.RET_STOP_ALL

            self.move_player[player.steam_id] = target_player.state.position
            player.team = "free"
        else:
            self.move_player[player.steam_id] = target_player.state.position
            minqlx.player_spawn(player.id)  # respawn player so he can't cheat
 def spawn(msg):
     if len(msg) < 2:
         minqlx.player_spawn(player.id)
     else:
         try:
             minqlx.player_spawn(int(msg[1]))
         except:
             player.tell("Invalid client ID. Please enter a client ID of the player to (re)spawn.")
 def cmd_respawn(self, player, msg, channel): # respawns the player. Will spawn a player no matter the team (spectators included ;))
     if len(msg) < 2:
         minqlx.player_spawn(player.id)
     else:
         try:
             minqlx.player_spawn(self.player(int(msg[1])).id)
         except:
             player.tell("Invalid client ID. Please enter a client ID of the player to (re)spawn.")
Ejemplo n.º 4
0
    def is_alive(self, value):
        if not isinstance(value, bool):
            raise ValueError("is_alive needs to be a boolean.")

        cur = self.is_alive
        if cur and value is False:
            # TODO: Proper death and not just setting health to 0.
            self.health = 0
        elif not cur and value is True:
            minqlx.player_spawn(self.id)
Ejemplo n.º 5
0
    def is_alive(self, value):
        if not isinstance(value, bool):
            raise ValueError("is_alive needs to be a boolean.")

        cur = self.is_alive
        if cur and value == False:
            # TODO: Proper death and not just setting health to 0.
            self.health = 0
        elif not cur and value == True:
            minqlx.player_spawn(self.id)
Ejemplo n.º 6
0
    def handle_client_command(self, player, cmd):
        """Disables readyup command if warmup ready % is more
        than 1. Spawns player right away if they use /kill and
        Removes them from goto and frame dicts."""
        if cmd == "readyup" and self.get_cvar("sv_warmupReadyPercentage", float) > 1:
            player.tell("readyup is disabled since sv_warmupReadyPercentage is more than 1")
            return minqlx.RET_STOP_EVENT

        if cmd == "kill" and player.team == "free":
            minqlx.player_spawn(player.id)
            self.goto.pop(player.steam_id, None)
            self.frame.pop(player.steam_id, None)
            return minqlx.RET_STOP_EVENT
 def handle_client_command(self, player, command):
     if self.game.state == "warmup":
         if command.lower() == "readyup":
             if player.team != "spectator":
                 if player not in self.readyPlayers:
                     self.center_print("{}^7 is ^2READY!".format(player))
                     self.readyPlayers.append(player)
                 else:
                     self.center_print("{}^7 is ^1NOT READY!".format(player))
                     self.readyPlayers.remove(player)
         elif command.lower() == "team s":
             if player.team == "spectator" and self.get_cvar("qlx_specsAliveDuringWarmup", bool):
                 minqlx.player_spawn(player.id)
Ejemplo n.º 8
0
    def cmd_loadpos(self, player, msg, channel):
        """Loads saved position."""
        if self.game.map.lower() in GOTO_DISABLED:
            player.tell("^1!loadpos is disabled on {}".format(self.game.map))
            return minqlx.RET_STOP_ALL

        if player.team != "spectator":
            if player.steam_id in self.savepos:
                self.move_player[player.steam_id] = self.savepos[player.steam_id]
                minqlx.player_spawn(player.id)  # respawn player so he can't cheat
            else:
                player.tell("^1You have to save your position first.")
        else:
            player.tell("^1Can't load position as spectator.")
        return minqlx.RET_STOP_ALL
Ejemplo n.º 9
0
 def process_team_switch(self, player, team):
     if self.game.state in ["in_progress", "countdown"]:
         if team in ['red', 'blue']:
             if self.add_new and not self.countdown and not player.is_alive:
                 if player.steam_id in self.went_to_spec:
                     self.went_to_spec.remove(player.steam_id)
                     team_slot = 0 if team == "red" else 1
                     with self.lock:
                         self.dead_players[player.id] = time.time() + self.team_timeout[team_slot]
                     self.team_timeout[team_slot] += self.add_seconds
                 else:
                     minqlx.player_spawn(player.id)
                     self.give_power_up(player)
         else:
             if player.steam_id not in self.went_to_spec:
                 self.went_to_spec.append(player.steam_id)
             with self.lock:
                 if player.id in self.dead_players:
                     del self.dead_players[player.id]
Ejemplo n.º 10
0
 def start_timer(self):
     count = 0
     current = time.time()
     while self.game.state in ["in_progress", "countdown"]:
         keys = []
         with self.lock:
             for key, value in self.dead_players.items():
                 if value <= current:
                     minqlx.player_spawn(key)
                     self.give_power_up(self.player(key))
                     keys.append(key)
             for key in keys:
                 del self.dead_players[key]
         time.sleep(0.01)
         current = time.time()
         count += 1
         if count >= 100:
             count = 0
             with self.lock:
                 for key, value in self.dead_players.items():
                     self.player(key).center_print("^4Respawn in ^1{} ^4seconds".format(int(value - current)))
Ejemplo n.º 11
0
 def delay_spawn():
     minqlx.player_spawn(victim.id)
 def handle_death(self, victim, killer, data):
     if self.game.state == "warmup" and victim.team == "spectator" and self.get_cvar("qlx_specsAliveDuringWarmup", bool):
         minqlx.player_spawn(victim.id)
Ejemplo n.º 13
0
 def delay_spawn():
     minqlx.player_spawn(victim.id)