Rust+.py Docs
  • Getting Started
    • Welcome to the Rust+.py Docs!
    • Quick Start
    • Getting Player Details
      • FCM Listener
      • Getting Entity ID's
    • RustSocket
      • Rate Limiting
  • API methods
    • Removing Listeners
    • Getting Team Info
    • Getting Team Chat
    • Getting Server Info
    • Getting the Map
    • Sending Messages
    • Getting the Time
    • Getting Entity Information
    • Getting Map Markers
    • Getting Contents of Monitors
    • Promoting Players to Team Leader
  • Command System
    • Commands Overview
    • Command Options
    • Command Decorator
    • Hanging The Socket
  • Event System
    • Events Overview
  • Cameras
    • Camera Managers
Powered by GitBook
On this page
  • Entity Event
  • Team Event
  • Chat Event
  • Protobuf Event
  • Removing

Was this helpful?

  1. Event System

Events Overview

Socket Events are called whenever a specific action / event happens. There are currently 4 possible types of event that you could listen for:

  • Chat Event

  • Entity Event

  • Team Event

  • Protobuf Event

These will be called by the socket when the respective events occur. Here are some example usages:

listeners.py
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)

Entity Event

Name
Description

entity_id

The Entity Id

value

The value of the entity, boolean

capacity

The capacity of the entity

has_protection

Whether the entity is protected by TC

protection_expiry

When the protection by TC will expire

items

The items that the entity contains

Team Event

This event is typically called when the team changes, e.g. a player leaves or joins. The team_event decorator will pass a TeamEvent object as a parameter with the following information:

Name
Description

player_info

The player_id of the changed information

team_info

Chat Event

This event is called when a message is sent to the team chat. It will give you a ChatEvent object when called with this information:

Name
Description

message

Protobuf Event

This event is called when protobuf is received over the websocket connection. This is for monitoring only. You are given the raw bytes of the message as a parameter.

Removing

To remove any listener see:

PreviousHanging The SocketNextCamera Managers

Last updated 8 days ago

Was this helpful?

The entity_event decorator takes an extra parameter of the that you are listening for changes to. The EntityEvent object holds information on the entity:

The on the team that changed

The that was sent

entity id
Removing Listeners
team info
message