### Install Rustplus Library Source: https://github.com/olijeffers0n/rustplus/blob/master/README.md Install the Rustplus Python package using pip. This is the primary method for setting up the library for use in your projects. ```bash pip install rustplus ``` -------------------------------- ### main.py Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/getting-started/getting-player-details/fcm-listener.md This Python script demonstrates how to set up and start an FCM listener. It loads FCM details from a configuration file and defines a custom listener class that prints received notifications. ```python from rustplus import FCMListener import json with open("rustplus.py.config.json", "r") as input_file: fcm_details = json.load(input_file) class FCM(FCMListener): def on_notification(self, obj, notification, data_message): print(notification) FCM(fcm_details).start() ``` -------------------------------- ### main.py Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/command-system/commands-overview.md This Python snippet demonstrates the basic setup for using commands in Rust+. It initializes the RustSocket with command options and defines a simple 'hi' command that responds to team chat messages. ```python from rustplus import RustSocket, CommandOptions, Command, ServerDetails, Command, ChatCommand options = CommandOptions(prefix="!") # Use whatever prefix you want here server_details = ServerDetails("IP", "PORT", STEAMID, PLAYERTOKEN) socket = RustSocket(server_details, command_options=options) @Command(server_details) async def hi(command : ChatCommand): await socket.send_team_message(f"Hi, {command.sender_name}") ``` -------------------------------- ### Connect to Rust Server and Get Time Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/getting-started/quick-start.md Connect to a Rust server using your server details and retrieve the current server time. Ensure you have obtained your SteamID and PlayerToken. ```python import asyncio from rustplus import RustSocket, ServerDetails async def main(): server_details = ServerDetails("IP", "PORT", STEAMID, PLAYERTOKEN) socket = RustSocket(server_details) await socket.connect() print(f"It is {(await socket.get_time()).time}") await socket.disconnect() asyncio.run(main()) ``` -------------------------------- ### Get Camera Manager Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/cameras/camera-managers.md Obtain a camera manager instance from the socket for a specific camera ID. Only one camera manager can be active at a time. ```python camera_manager = await socket.get_camera_manager("drone") # The parameter is the camera ID ``` -------------------------------- ### Get Map Image with Additions Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-the-map.md Retrieves a PIL.Image of the map with optional additions like icons, events, vending machines, team positions, and grid. ```python rust_socket.get_map(add_icons=True, add_events=True, add_vending_machines=True, add_team_positions=True, override_images={}, add_grid=True) ``` -------------------------------- ### Get Camera Frame Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/cameras/camera-managers.md Fetch the latest camera frame as a PIL Image. Use `camera_manager.has_frame_data()` to check if frame data is available before attempting to retrieve it. ```python camera_manager = await socket.get_camera_manager("drone") image = await camera_manager.get_frame() # PIL Image ``` -------------------------------- ### Get Map Information Data Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-the-map.md Fetches structured map data including dimensions, image bytes, monuments, and background. ```python rust_socket.get_map_info() ``` -------------------------------- ### Get Map Markers Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-map-markers.md The `get_markers()` method returns a list of `RustMarker` objects, each containing detailed information about a specific marker on the map. This includes its ID, type, position, associated player or entity data, and visual properties. ```APIDOC ## get_markers() ### Description Retrieves a list of all map markers currently present on the server. Each marker object contains detailed information about its type, position, and associated data. ### Method `rust_socket.get_markers()` ### Returns `List[RustMarker]` - A list of RustMarker objects. ### RustMarker Object Fields: - **id** (int) - Unique identifier for the marker. - **type** (int) - The type of the marker (e.g., Player, Explosion, VendingMachine). - **x** (float) - The x-coordinate of the marker. - **y** (float) - The y-coordinate of the marker. - **steam_id** (int) - The Steam ID associated with the marker (if applicable). - **rotation** (float) - The rotation of the marker. - **radius** (float) - The radius of the marker. - **colour1** (RustColour) - The primary color of the marker. - **colour2** (RustColour) - The secondary color of the marker. - **alpha** (float) - The transparency of the marker. - **name** (str) - The name of the marker. - **sell_orders** (List[RustSellOrder]) - A list of sell orders associated with the marker (if applicable). ### RustColour Object Fields: - **x** (float) - **y** (float) - **z** (float) - **w** (float) ### RustSellOrder Object Fields: - **item_id** (int) - **quantity** (int) - **currency_id** (int) - **cost_per_item** (int) - **item_is_blueprint** (bool) - **currency_is_blueprint** (bool) - **amount_in_stock** (int) ### Marker Types: - **Player** = 1 - **Explosion** = 2 - **VendingMachine** = 3 - **CH47** = 4 - **CargoShip** = 5 - **Crate** = 6 - **GenericRadius** = 7 - **PatrolHelicopter** = 8 ``` -------------------------------- ### Getting the Map Data Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-the-map.md Retrieves the map's metadata, including dimensions, image data, and monument information. ```APIDOC ## get_map_info ### Description Retrieves the map's metadata. ### Method `rust_socket.get_map_info()` ### Response - Returns a `RustMap` object containing map details. ### RustMap Object - **width** (int) - The width of the map. - **height** (int) - The height of the map. - **jpg_image** (bytes) - The map image data in JPEG format. - **margin** (int) - The margin of the map. - **monuments** (List[RustMonument]) - A list of monuments on the map. - **background** (str) - The background identifier for the map. ### RustMonument Object - **token** (str) - The token identifier for the monument. - **x** (float) - The x-coordinate of the monument. - **y** (float) - The y-coordinate of the monument. ``` -------------------------------- ### Getting the Map Image Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-the-map.md Retrieves the map image with specified additions like icons, events, team positions, and grid. Supports overriding default images. ```APIDOC ## get_map ### Description Retrieves the map image with specified additions. ### Method `rust_socket.get_map(add_icons: bool, add_events: bool, add_vending_machines: bool, add_team_positions: bool, override_images: dict, add_grid: bool)` ### Parameters - **add_icons** (bool) - Whether to add icons to the map. - **add_events** (bool) - Whether to add events to the map. - **add_vending_machines** (bool) - Whether to add vending machines to the map. - **add_team_positions** (bool) - Whether to add team positions to the map. - **override_images** (dict) - A dictionary to override default images. - **add_grid** (bool) - Whether to add a grid to the map. ### Response - Returns a `PIL.Image` object representing the map. ``` -------------------------------- ### Get Entity Info Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-entity-information.md Retrieves detailed information about a specific entity using its ID. This method returns a RustEntityInfo object containing various attributes of the entity. ```APIDOC ## get_entity_info ### Description Retrieves detailed information about a specific entity using its ID. This method returns a RustEntityInfo object containing various attributes of the entity. ### Method `rust_socket.get_entity_info(entity_id: int)` ### Parameters #### Path Parameters - **entity_id** (int) - Required - The unique identifier of the entity. ### Response #### Success Response - **type** (int) - The type of the entity (e.g., Switch, Alarm, StorageMonitor). - **value** (bool) - The current value or state of the entity. - **items** (RustEntityInfoItem) - Information about items associated with the entity. - **capacity** (int) - The capacity of the entity. - **has_protection** (bool) - Indicates if the entity has protection enabled. - **protection_expiry** (int) - The expiration time for entity protection. ### Response Example ```json { "type": 1, "value": true, "items": { "item_id": 123, "quantity": 10, "item_is_blueprint": false }, "capacity": 100, "has_protection": true, "protection_expiry": 1678886400 } ``` ### Entity Types - **Switch**: 1 - **Alarm**: 2 - **StorageMonitor**: 3 ``` -------------------------------- ### Get Team Chat Messages Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-team-chat.md Call the `get_team_chat()` method on your `rust_socket` object to retrieve a list of team chat messages. Each message object contains details such as sender ID, name, message content, color, and timestamp. ```APIDOC ## get_team_chat() ### Description Retrieves a list of team chat messages. ### Method rust_socket.get_team_chat() ### Response #### Success Response - **List[RustChatMessage]**: A list of chat message objects. ### RustChatMessage Fields - **steam_id** (int) - The Steam ID of the sender. - **name** (str) - The display name of the sender. - **message** (str) - The content of the chat message. - **colour** (str) - The color associated with the message (e.g., hex code). - **time** (int) - The timestamp when the message was sent. ``` -------------------------------- ### Initialize RustSocket with Player Details Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/getting-started/getting-player-details/README.md This Python snippet shows how to initialize the RustSocket using the player details obtained from the pairing process. Ensure you have the correct IP address, port, Steam ID, and Player Token. ```python rust_socket = RustSocket("IPADDRESS", "PORT", 64BITSTEAMID, PLAYERTOKEN) ``` -------------------------------- ### Initialize CommandOptions with a Prefix Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/command-system/command-options.md Use CommandOptions to set the prefix for your commands. This is the character that must precede a command for it to be recognized. ```python from rustplus import CommandOptions options = CommandOptions(prefix="!") ``` -------------------------------- ### Initialize RustSocket Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/getting-started/rustsocket/README.md Constructs a RustSocket instance with essential and optional parameters. Use this to establish a connection to a Rust server for interacting with its API. ```python from rustplus import RustSocket socket = RustSocket(ip, port, steam_id, player_token, command_options, raise_ratelimit_exception, ratelimit_limit, ratelimit_refill, use_proxy) ``` -------------------------------- ### get_info() Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-server-info.md Retrieves a RustInfo object containing various details about the server. ```APIDOC ## get_info() ### Description Calls the `get_info()` method to fetch server details. ### Method `rust_socket.get_info()` ### Response #### Success Response Returns a `RustInfo` object with the following fields: - **url** (str) - The server URL. - **name** (str) - The server name. - **map** (str) - The map name. - **size** (int) - The server map size. - **players** (int) - The current number of players. - **max_players** (int) - The maximum number of players allowed. - **queued_players** (int) - The number of players in the queue. - **seed** (int) - The server seed. ``` -------------------------------- ### Convert Coordinates to Grid Reference Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-map-markers.md Demonstrates how to convert world coordinates (x, y) to a grid reference using the `convert_coordinates` function and map information. ```python from rustplus import convert_coordinates info = await rust_socket.get_info() if isinstance(info, RustError): print(f"Error Occurred, Reason: {info.reason}") grid = convert_coordinates((x, y), info.map_size) print(f"Grid Reference: {grid}") ``` -------------------------------- ### get_contents Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-contents-of-monitors.md Retrieves the contents of a specified monitor. It allows for combining stacks of items for a more concise representation. ```APIDOC ## get_contents ### Description Retrieves the contents of a specified monitor. It allows for combining stacks of items for a more concise representation. ### Method `get_contents(eid: int, combine_stacks: bool)` ### Parameters #### Path Parameters - **eid** (int) - Required - The entity ID of the monitor. - **combine_stacks** (bool) - Required - Whether to combine stacks of items. ### Response #### Success Response Returns a `RustContents` object containing the monitor's contents. ``` class RustContents with fields: protection_time: timedelta has_protection: bool contents : List[RustItem] class RustItem with fields: name: str item_id: int quantity: int is_blueprint: bool ``` ``` -------------------------------- ### Python Event Listeners Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/event-system/events-overview.md Set up listeners for various Rustplus events. Ensure entity info is fetched before listening to EntityEvents. These listeners are triggered when the respective events occur. ```python from rustplus import EntityEventPayload, TeamEventPayload, ChatEventPayload, ProtobufEvent, ChatEvent, EntityEvent, TeamEvent # You must call get_entity_info(eid) before an EntityEvent listener will receive any data. # This is to "subscribe" to the entity. @EntityEvent(server_details, 25743493) async def alarm(event: EntityEventPayload): value = "On" if event.value else "Off" print(f"Entity has been turned {value}") @TeamEvent(server_details) async def team(event: TeamEventPayload): print(f"The team leader's steamId is: {event.team_info.leader_steam_id}") @ChatEvent(server_details) async def chat(event: ChatEventPayload): print(f"{event.message.name}: {event.message.message}") @ProtobufEvent(server_details) async def proto(data: bytes): print(data) ``` -------------------------------- ### Register Command with String Aliases Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/command-system/command-decorator.md Register a command with multiple string aliases using the 'aliases' parameter. This allows the command to be invoked with any of the provided alias strings. ```python @ChatCommand(server_details, aliases=["hello", "hey"]) async def hi(command: ChatCommand): print("Command Ran!") ``` -------------------------------- ### Accessing First Member's Name Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-team-info.md Demonstrates how to call `get_team_info` and access the name of the first member in the returned team information. ```python info = await rust_socket.get_team_info() print(info.members[0].name) ``` -------------------------------- ### RustSocket Constructor with Rate Limiting Option Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/getting-started/rustsocket/rate-limiting.md Configure RustSocket to either raise an exception when rate limits are exceeded or to wait until sufficient tokens are available. The default behavior is to raise an exception. ```python RustSocket(raise_ratelimit_exception=False) ``` -------------------------------- ### RustContents and RustItem Object Structure Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-contents-of-monitors.md This defines the structure of the objects returned when retrieving monitor contents. `RustContents` includes protection status and a list of `RustItem` objects. Each `RustItem` details the item's name, ID, quantity, and blueprint status. ```python class RustContents with fields: protection_time: timedelta has_protection: bool contents : List[RustItem] class RustItem with fields: name: str item_id: int quantity: int is_blueprint: bool ``` -------------------------------- ### Control Drone and Camera Movements Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/cameras/camera-managers.md Send movement and action commands to the camera, such as firing or mouse movements. Remember to clear movement after use to prevent continuous action. ```python # Check that it is possible to zoom the camera in and out if camera_manager.can_move(CameraMovementOptions.FIRE) and \ camera_manager.can_move(CameraMovementOptions.MOUSE): # Send a MovementControl action to the camera await camera_manager.send_actions([MovementControls.FIRE_PRIMARY]) # You can also send just mouse movement or both at the same time: await camera_manager.send_mouse_movement(Vector(1, 1)) await camera_manager.send_combined_movement( [MovementControls.FIRE_PRIMARY], Vector(1, 1)) await asyncio.sleep(1) # You must clear the movement after you are done # as otherwise the mouse will continue to move and the server # Will consider the mouse still clicked down await camera_manager.clear_movement() ``` -------------------------------- ### get_time() Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-the-time.md Retrieves the current time information from the server. This method returns a RustTime object containing details about the server's day length, sunrise and sunset times, and the current time. ```APIDOC ## get_time() ### Description Retrieves the current time information from the server. This method returns a RustTime object containing details about the server's day length, sunrise and sunset times, and the current time. ### Method `rust_socket.get_time()` ### Response #### Success Response - **RustTime** (object) - An object containing time-related information. - **day_length** (float) - The length of a day on the server in seconds. - **sunrise** (str) - The time of sunrise in HH:MM:SS format. - **sunset** (str) - The time of sunset in HH:MM:SS format. - **time** (str) - The current server time in HH:MM:SS format. - **raw_time** (float) - The current server time as a Unix timestamp. ``` -------------------------------- ### Register a Command Listener Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/command-system/command-decorator.md Use the Command decorator to mark a coroutine as a command listener. The coroutine's name determines the command prefix. ```python from main import server_details @Command(server_details) async def hi(command: ChatCommand): print("Command Ran!") ``` -------------------------------- ### RustMarker Types Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-map-markers.md Lists the integer types and their corresponding string representations for different map markers. ```text Types: Player = 1 Explosion = 2 VendingMachine = 3 CH47 = 4 CargoShip = 5 Crate = 6 GenericRadius = 7 PatrolHelicopter = 8 ``` -------------------------------- ### get_team_info() Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-team-info.md Fetches detailed information about the player's team. This includes leader details, team members, and map notes. ```APIDOC ## get_team_info() ### Description Fetches detailed information about the player's team. This includes leader details, team members, and map notes. ### Method `rust_socket.get_team_info()` ### Returns - `RustTeamInfo`: An object containing team information. ### RustTeamInfo Structure - **leader_steam_id** (int) - The Steam ID of the team leader. - **members** (List[RustTeamMember]) - A list of team members. - **map_notes** (List[RustTeamNote]) - A list of map notes associated with the team. - **leader_map_notes** (List[RustTeamNote]) - A list of map notes specifically for the team leader. ### RustTeamMember Structure - **steam_id** (int) - The Steam ID of the team member. - **name** (str) - The name of the team member. - **x** (float) - The X-coordinate of the team member. - **y** (float) - The Y-coordinate of the team member. - **is_online** (bool) - Indicates if the team member is currently online. - **spawn_time** (int) - The time the member spawned. - **is_alive** (bool) - Indicates if the team member is currently alive. - **death_time** (int) - The time the member died. ### RustTeamNote Structure - **type** (int) - The type of the map note. - **x** (float) - The X-coordinate of the map note. - **y** (float) - The Y-coordinate of the map note. - **icon** (int) - The icon identifier for the map note. - **colour_index** (int) - The color index for the map note. - **label** (string) - The label or name of the map note. ### Example Usage ```python info = await rust_socket.get_team_info() print(info.members[0].name) ``` ``` -------------------------------- ### Resubscribe to Camera Feed Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/cameras/camera-managers.md Resubscribe to the camera feed if the last subscription has expired. This is necessary because subscriptions only last about 15 seconds. ```python if time.time() - camera_manager.time_since_last_subscribe > 10: await camera_manager.resubscribe() ``` -------------------------------- ### Player Details JSON Structure Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/getting-started/getting-player-details/README.md This JSON structure represents the details received after pairing with a server. It includes essential information such as IP address, port, Steam Player ID, and a unique Player Token. ```json { "desc": "",se "id": "", "img": "", "ip": "", <- This is the IP "logo": "", "name": "", "playerId": "", <- This is your steam player ID "playerToken": "", <- This is your unique token "port": "", <- This is the port "type": "", "url": "" } ``` -------------------------------- ### Register Command with Alias Function Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/command-system/command-decorator.md Register a command with a dynamic alias check using 'alais_func'. This function receives the command string and returns true if it should be considered a match. ```python @ChatCommand(server_details, alais_func=lambda x: x.lower() == "test") async def pair(command: ChatCommand): print("Command Ran!") ``` -------------------------------- ### Setting Entity Value Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-entity-information.md This method allows you to change the state of an entity. Use it to toggle switches or activate/deactivate alarms. ```python rust_socket.set_entity_value(entity_id: int, value: bool) ``` -------------------------------- ### Promote to Team Leader Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/promoting-players-to-team-leader.md Promotes a player in your team to the leader role using their Steam ID. ```APIDOC ## promote_to_team_leader ### Description Promotes the specified player in your team to the leader role. ### Method rust_socket.promote_to_team_leader ### Parameters #### Path Parameters - **steam_id** (int) - Required - The Steam ID of the player to promote. ``` -------------------------------- ### Hang the Socket to Listen for Commands Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/command-system/hanging-the-socket.md Use this method to prevent your script from terminating before you can listen for commands. This will keep the script running indefinitely until force-closed. ```python await rust_socket.hang() ``` -------------------------------- ### RustInfo Data Structure Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-server-info.md The `RustInfo` object returned by `rust_socket.get_info()` contains various server details. This structure outlines the available fields. ```python class RustInfo with fields: url: str name: str map: str size: int players: int max_players: int queued_players: int seed: int ``` -------------------------------- ### RustMarker Data Structure Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-map-markers.md Defines the fields available for a RustMarker object, including its ID, type, position, and associated data like sell orders. ```python class RustMarker with fields: id: int type: int x: float y: float steam_id: int rotation: float radius: float colour1 : RustColour colour2 : RustColour alpha: float name: str sell_orders : List[RustSellOrder] class RustColour with fields: x: float y: float z: float w: float class RustSellOrder with fields: item_id: int quantity: int currency_id: int cost_per_item: int item_is_blueprint: bool currency_is_blueprint: bool amount_in_stock: int ``` -------------------------------- ### RustEntityInfo Data Structure Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-entity-information.md This structure represents the information returned when querying an entity's details. It includes type, value, items, capacity, and protection status. ```python class RustEntityInfo with fields: type: int value: bool items : RustEntityInfoItem capacity: int has_protection: bool protection_expiry: int class RustEntityInfoItem with fields: item_id: int quantity: int item_is_blueprint: bool ``` -------------------------------- ### RustTime Object Fields Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-the-time.md The `get_time()` method returns a `RustTime` object. This object contains details about the server's time, including day length, sunrise and sunset times, and the current time. ```python class RustTime with fields: day_length: float sunrise: str sunset: str time: str raw_time: float ``` -------------------------------- ### RustTeamInfo Data Structure Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-team-info.md Defines the fields available within the `RustTeamInfo` object returned by the `get_team_info` method. This includes leader details, members, and map notes. ```python class RustTeamInfo with fields: leader_steam_id: int members : List[RustTeamMember] map_notes : List[RustTeamNote] leader_map_notes : List[RustTeamNote] class RustTeamMember with fields: steam_id: int name: str x: float y: float is_online: bool spawn_time: int is_alive: bool death_time: int class RustTeamNote with fields: type: int x: float y: float icon: int colour_index: int label: string ``` -------------------------------- ### Send Team Message in Python Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/sending-messages.md Use this method to send a message to your team chat. Ensure you are properly authenticated with RustSocket. ```python await rust_socket.send_team_message("Hi! This was sent with Rust+.py") ``` -------------------------------- ### Convert Coordinates to Grid Reference Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-map-markers.md This utility function converts raw map coordinates (x, y) into a grid reference string, using the server's map size information. This is useful for displaying marker locations in a more human-readable format. ```APIDOC ## Convert Coordinates to Grid Reference ### Description Converts a given coordinate pair (x, y) into a grid reference string based on the server's map dimensions. This is useful for displaying marker locations in a user-friendly format. ### Method `convert_coordinates((x, y), map_size)` ### Parameters #### Path Parameters - **(x, y)** (tuple[float, float]) - Required - The x and y coordinates to convert. - **map_size** (int) - Required - The size of the map. ### Returns `str` - The grid reference string (e.g., "A1"). ### Example ```python from rustplus import convert_coordinates # Assuming 'x', 'y', and 'info.map_size' are already defined # info = await rust_socket.get_info() # grid = convert_coordinates((x, y), info.map_size) # print(f"Grid Reference: {grid}") ``` ``` -------------------------------- ### Unregistering a Specific Entity Event Listener Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/removing-listeners.md Demonstrates how to unregister a specific listener function for an entity event using its HandlerList. This is useful when you no longer need to react to a particular event from a specific entity. ```python import asyncio from rustplus import EntityEvent, EntityEventPayload from rustplus.rustplus import RustSocket async def on_entity_event(payload: EntityEventPayload): await rust_socket.set_entity_value(payload.entity_id, not payload.value) EntityEventPayload.HANDLER_LIST.unregister(on_entity_event, server_details) # You can also unregister all listeners for a specific event EntityEventPayload.HANDLER_LIST.unregister_all() ``` -------------------------------- ### Entity Type Mapping Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-entity-information.md Provides a mapping of integer entity types to their corresponding names. This is useful for interpreting the 'type' field from `RustEntityInfo`. ```plaintext Switch = 1 Alarm = 2 StorageMonitor = 3 ``` -------------------------------- ### Handle Rust API Errors Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/getting-started/quick-start.md Check if an API method returned a RustError. This allows for robust error handling and server reconnection logic. ```python time = await socket.get_time() if isinstance(time, RustError): print(f"Error Occurred, Reason: {time.reason}") ``` -------------------------------- ### RustChatMessage Structure Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-team-chat.md Defines the structure of a team chat message object returned by the API. Fields include sender ID, name, message content, color, and timestamp. ```python class RustChatMessage with fields: steam_id: int name: str message: str colour: str time: int ``` -------------------------------- ### send_team_message Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/sending-messages.md Sends a message to the team chat. This message will appear as if sent by the player logged in via Rust+. ```APIDOC ## send_team_message ### Description Sends a message to the team chat. This message will appear as if sent by the player logged in via Rust+. ### Method ```python await rust_socket.send_team_message(message: str) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **message** (str) - Required - The message content to send to the team chat. ### Request Example ```python await rust_socket.send_team_message("Hi! This was sent with Rust+.py") ``` ### Response #### Success Response (200) This method does not explicitly define a success response body in the documentation. It is assumed to return a success status upon completion. #### Response Example None explicitly provided. ``` -------------------------------- ### Set Entity Value Source: https://github.com/olijeffers0n/rustplus/blob/master/docs/api-methods/getting-entity-information.md Sets the value of a specified entity. This is useful for controlling entities like switches or alarms. ```APIDOC ## set_entity_value ### Description Sets the value of a specified entity. This is useful for controlling entities like switches or alarms. ### Method `rust_socket.set_entity_value(entity_id: int, value: bool)` ### Parameters #### Path Parameters - **entity_id** (int) - Required - The unique identifier of the entity. - **value** (bool) - Required - The desired value to set for the entity. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.