From d1c58b64e47644f60ab56d1171f14d69266d176f Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Fri, 7 Jul 2023 18:15:39 +0300 Subject: [PATCH] Plugins and Events documentation --- README.md | 2 +- docs/plugins and events.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 docs/plugins and events.md diff --git a/README.md b/README.md index 9576cbb..2ac7cc6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/plugins and events.md b/docs/plugins and events.md new file mode 100644 index 0000000..b0dc1d3 --- /dev/null +++ b/docs/plugins and events.md @@ -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)`