Skip to content

Commit

Permalink
GitBook: No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n authored and gitbook-bot committed Jul 31, 2023
1 parent d21bb2e commit 9c6de62
Show file tree
Hide file tree
Showing 29 changed files with 721 additions and 0 deletions.
Binary file added docs/.gitbook/assets/Untitled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Welcome to the Rust+.py Docs!

![](.gitbook/assets/icon.png)

Welcome to Rust+.py! Here you'll find all the documentation you need to get up and running with API.

## Want to jump right in?

Feeling like an eager beaver? Jump in to the quick start docs and get making your first requests:

{% content-ref url="getting-started/quick-start.md" %}
[quick-start.md](getting-started/quick-start.md)
{% endcontent-ref %}

## Want to take a look at our source?

Head over to our GitHub repository [here](https://github.com/olijeffers0n/rustplus)

## Need some help?

Head over to our discord server [here](https://lt.ollieee.xyz/rplusdiscord)

42 changes: 42 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Table of contents

## Getting Started

* [Welcome to the Rust+.py Docs!](README.md)
* [Quick Start](getting-started/quick-start.md)
* [Getting Player Details](getting-started/getting-player-details/README.md)
* [FCM Listener](getting-started/getting-player-details/fcm-listener.md)
* [Getting Entity ID's](getting-started/getting-player-details/getting-entity-ids.md)
* [RustSocket](getting-started/rustsocket/README.md)
* [Rate Limiting](getting-started/rustsocket/rate-limiting.md)

## API methods

* [Removing Listeners](api-methods/removing-listeners.md)
* [Getting Team Info](api-methods/getting-team-info.md)
* [Getting Team Chat](api-methods/getting-team-chat.md)
* [Getting Server Info](api-methods/getting-server-info.md)
* [Getting the Map](api-methods/getting-the-map.md)
* [Sending Messages](api-methods/sending-messages.md)
* [Getting the Time](api-methods/getting-the-time.md)
* [Getting Entity Information](api-methods/getting-entity-information.md)
* [Getting Map Markers](api-methods/getting-map-markers.md)
* [Getting Current Map Events](api-methods/getting-current-map-events.md)
* [Getting Contents of Monitors](api-methods/getting-contents-of-monitors.md)
* [Promoting Players to Team Leader](api-methods/promoting-players-to-team-leader.md)
* [Toggling Smart Switches](api-methods/toggling-smart-switches.md)

## Command System

* [Commands Overview](command-system/commands-overview.md)
* [Command Options](command-system/command-options.md)
* [Command Decorator](command-system/command-decorator.md)
* [Hanging The Socket](command-system/hanging-the-socket.md)

## Event System

* [Events Overview](event-system/events-overview.md)

## Cameras

* [Camera Managers](cameras/camera-managers.md)
21 changes: 21 additions & 0 deletions docs/api-methods/getting-contents-of-monitors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Getting Contents of Monitors

Calling `rust_socket.get_contents(eid: int, combine_stacks: bool)` returns a `RustContents` object:



```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
```

12 changes: 12 additions & 0 deletions docs/api-methods/getting-current-map-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Getting Current Map Events

The following are all defined as "events":

* Explosions (Bradley / Attack Helicopter)
* Cargo Ship
* CH47 (Chinook)
* Locked Crates
* Attack Helicopter

Calling `rust_socket.get_current_events()` returns a list of all current `RustMarker`'s that are the above events. This can be used for working out whether Cargo Ship / Oil Rig etc has been taken / is being taken. See [Here ](getting-map-markers.md)for information on `RustMarker`

29 changes: 29 additions & 0 deletions docs/api-methods/getting-entity-information.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Getting Entity Information

Calling `rust_socket.get_entity_info(entity_id: int)` will return a `RustEntityInfo` object with the following data:

```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
```

The entity type is an integer value which corresponds to these values:

```
Switch = 1
Alarm = 2
StorageMonitor = 3
```

52 changes: 52 additions & 0 deletions docs/api-methods/getting-map-markers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Getting Map Markers

Calling `rust_socket.get_markers()` returns a `List[RustMarker]` with the following data:

```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
```

#### These are the types of the RustMarker

```
Types:
Player = 1
Explosion = 2
VendingMachine = 3
CH47 = 4
CargoShip = 5
Crate = 6
GenericRadius = 7
PatrolHelicopter = 8
```

17 changes: 17 additions & 0 deletions docs/api-methods/getting-server-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Getting Server Info

Calling `rust_socket.get_info()` will return a `RustInfo` object with the following data:

```python
class RustInfo with fields:

url: str
name: str
map: str
size: int
players: int
max_players: int
queued_players: int
seed: int
```

14 changes: 14 additions & 0 deletions docs/api-methods/getting-team-chat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Getting Team Chat

Calling `rust_socket.get_team_chat()` will return a `List[RustChatMessage]` objects with fields:

```python
class RustChatMessage with fields:

steam_id: int
name: str
message: str
colour: str
time: int
```

37 changes: 37 additions & 0 deletions docs/api-methods/getting-team-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Getting Team Info

Calling `rust_socket.get_team_info()` returns a `RustTeamInfo` object with the following data:

```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
x: float
y: float
```

So, to get the name of the first member in the team you can do:

```python
info = await rust_socket.get_team_info()
print(info.members[0].name)
```

27 changes: 27 additions & 0 deletions docs/api-methods/getting-the-map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Getting the Map

### Getting the Image

Calling `rust_socket.get_map(add_icons: bool, add_events: bool, add_vending_machines: bool, override_images: dict)` will return a `PIL.Image` with the respective additions.

### Getting the Map Data

Calling `rust_socket.get_raw_map_data()` will return a `RustMap` object with the following data:

```python
class RustMap with fields:

width: int
height: int
jpg_image: bytes
margin: int
monuments : List[RustMonument]
background: str

class RustMonument with fields:

token: str
x: float
y: float
```

14 changes: 14 additions & 0 deletions docs/api-methods/getting-the-time.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Getting the Time

Calling `rust_socket.get_time()` returns a `RustTime` object with the following info:

```python
class RustTime with fields:

day_length: float
sunrise: str
sunset: str
time: str
raw_time: float
```

4 changes: 4 additions & 0 deletions docs/api-methods/promoting-players-to-team-leader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Promoting Players to Team Leader

Calling `rust_socket.promote_to_team_leader(steam_id: int)` will promote the player in your team to the leader.

10 changes: 10 additions & 0 deletions docs/api-methods/removing-listeners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Removing Listeners

### Registered Listeners

A registered listener is a wrapper object around the coroutine itself that will allow the listener to be removed later on. Should you need the coroutine back, call `RegisteredListener.get_coro()`.

### Removing The listener

Removing a listener is as simple as calling `RustSocket.remove_listener(RegisteredListener)` and will return a boolean value. True if a listener was removed and false otherwise

8 changes: 8 additions & 0 deletions docs/api-methods/sending-messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Sending Messages

Calling `rust_socket.send_team_message(message: str)` will send the message to the team chat as the player who you are logged in as in the [`RustSocket`](../getting-started/rustsocket/) . For example:

```python
await rust_socket.send_team_message("Hi! This was sent with Rust+.py")
```

8 changes: 8 additions & 0 deletions docs/api-methods/toggling-smart-switches.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Toggling Smart Switches

Calling `rust_socket.turn_on_smart_switch(eid: int)` and `rust_socket.turn_off_smart_switch(eid: int)` can be used to toggle smart switches on and off from code. To get the entity\_ids look at:

{% content-ref url="../getting-started/getting-player-details/getting-entity-ids.md" %}
[getting-entity-ids.md](../getting-started/getting-player-details/getting-entity-ids.md)
{% endcontent-ref %}

55 changes: 55 additions & 0 deletions docs/cameras/camera-managers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Camera Managers

A camera manager facilitates all operations with cameras inside Rust.

Creation:

```python
# Get the camera manager from the socket:
camera_manager = await socket.get_camera_manager("drone")
# The parameter is the camera ID
```

**Only one Camera Manager can exist at once**. Once a new one is created the old one will go stale.

## Re Subscribing

Subscriptions only last around 15 seconds. After this, you must resubscribe by doing:

```python
if time.time() - camera_manager.time_since_last_subscribe > 10:
await camera_manager.resubscribe()
```

## Getting Frames

Camera frames can be fetched for the camera using the following:

```python
camera_manager = await socket.get_camera_manager("drone")
image = await camera_manager.get_frame() # PIL Image
```

This returns a `PIL` Image that can be saved or displayed. When the Camera Manager is first created there is no camera frame available. Use: `camera_manager.has_frame_data()` to check for this.

## Controlling Drones and Cameras

There are many possible movement options that can be sent via the following code:

```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()
```
Loading

0 comments on commit 9c6de62

Please sign in to comment.