def display_name(self, name): if not name: return # Just get a single player based on the name. In the future I may # make this thing get multiple player's location info. players = rcon_client.get_players(names=[name]) print players if players: player = players.values()[0] else: return # They don't have location information. Go grab it. if 'country' not in player: if 'ip' not in player: print 'Error: Player has no ip.' return data = self.lookup_ip(player['ip']) # Save the information for later player.update(data) rcon_client.hsay(player['name'], '%s, %s, %s (%s)' % (player['city'], player['region'], player['country'], player['area_code']))
def on_command(self, command, params, silent, **kwargs): extra = kwargs.get('extra', {}) uniqueid = extra.get('uniqueid', '') # We don't have access. Return. if not has_access(uniqueid, 'admin'): # Keep processing other plugins. return True # No reason to do anything if we're silent. if silent: return True players = None if command == 'id': # If they passed params, then get the players by their names parsed_commands = shell_parse(params) if parsed_commands: players = rcon_client.get_players(names=parsed_commands) else: # Otherwise, just use all the players players = rcon_client.get_players() elif command == 'idteam' and params: # Get the correct team name based on what they passed. team = None if params == 'c' or params == 'ct': team = 'CT' elif params == 't': team = 'TERRORIST' # If we have a team, get the players on that team. if team: players = rcon_client.find_players('team', team) if players: reactor.callInThread(self.display_players, players) # Keep processing other plugins. return True