Plugins and Events documentation

This commit is contained in:
Maxim Khomutov 2023-07-07 18:15:39 +03:00
parent b4c200c31b
commit d1c58b64e4
2 changed files with 34 additions and 1 deletions

View File

@ -23,7 +23,7 @@ BeamingDrive Multiplayer (BeamMP) server compatible with BeamMP clients.
- [x] Tabulation
- [ ] _(Deferred)_ Normal text scroll
- [ ] Documentation:
- [x] [Plugins and Events](docs/plugins.md)
- [x] [Plugins and Events](docs/plugins and events.md)
## Installation

View File

@ -0,0 +1,33 @@
# Plugins System
## Install
[//]: # (TODO: BEAM LIB)
Lib can't ready to use
* From pip:\
`$ pip install ...`
* From source:\
`git clone https://github.com/kuitoi/...`
## Example
```python
import BEAMP
beam = BEAMP("TestPlugin")
logger = beam.log
def load(): # Plugins load from here
print(beam.name)
def on_started():
logger.info("Server starting...")
beam.register_event("on_started", on_started)
```
* Basic Events: ['on_started', 'on_auth, 'on_stop']
* Create new event : `beam.register_event("my_event", my_event_function)`
* Call event: `beam.call_event("my_event")`
* Call event with some data: `beam.call_event("my_event", data, data2)`
* Calls _**can't support**_ like this: `beam.call_event("my_event", data=data)`