docs: Added docs for Packet class and onPacket event

fix: Added missing sendToAll method
This commit is contained in:
AURUMVORXX
2024-11-05 03:33:46 +03:00
parent 2657b2c613
commit 5389f6dcb4
4 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
# `event` onPacket
This event is triggered when new packet arrives from the client.
Original: [onPacket](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-events/network/onPacket/)
## Parameters
* `dict` **kwargs**:
* `int` **playerid**: the id of the player who sent the packet.
* `Packet` **packet**: data sended over network from client side.
## Usage
```python
import g2o
@g2o.event('onPacket')
def onPacketEvt(**kwargs):
data = kwargs['data']
message = data.readString()
print(f'Got packet from {kwargs['playerid']} (bytes used {data.bytesUsed})')
print(f'Packet says: {message}')
```