diff --git a/sampquery/__init__.py b/sampquery/__init__.py index de4e382..15c18b4 100644 --- a/sampquery/__init__.py +++ b/sampquery/__init__.py @@ -3,7 +3,7 @@ from .client import SAMPQuery_Client __name__ = "sampquery" -__version__ = "0.0.1" +__version__ = "0.0.8" __author__ = "larayavrs" __email__ = "larayavrs@gmail.com" diff --git a/sampquery/client.py b/sampquery/client.py index 513bc2f..e23c734 100644 --- a/sampquery/client.py +++ b/sampquery/client.py @@ -254,4 +254,50 @@ async def rcon(self, command: str) -> str: except TimeoutError as e: raise TimeoutError( "Failed to retrieve RCON response due to a timeout. The server may be unresponsive." - ) from e \ No newline at end of file + ) from e + + async def ping_history(self, samples: int = 5, interval: float = 1.0) -> list[float]: + """ + Perform multiple ping measurements to the server and return a list with the results. + + :param samples: Number of measurements to perform. + :param interval: Interval in seconds between each measurement. + :return: List of ping times (in seconds). + """ + results = [] + for _ in range(samples): + ping = await self.__ping() + results.append(ping) + if _ < samples - 1: + await trio.sleep(interval) + return results + + async def server_version(self) -> str: + """ + Retrieve the server version. + + :return str: The server version. + """ + info = await self.info() + return getattr( + info, "version", "Unknown" + ) + + async def players_with_score(self, min_score: int = 0) -> list: + """ + Returns a list of players whose score is greater than or equal to min_score. + + :param min_score: Minimum required score. + :return: List of players that meet the criteria. + """ + players = await self.detailed_players() + return [p for p in players if getattr(p, "score", 0) >= min_score] + + async def free_slots(self) -> int: + """ + Returns the number of free slots on the server. + + :return: Number of free slots. + """ + info = await self.info() + return getattr(info, "max_players", 0) - getattr(info, "players", 0) \ No newline at end of file