From d76262fc43761a5aada744f30f393321c804722f Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Sun, 23 Jul 2023 00:17:32 +0300 Subject: [PATCH] Fix --- docs/en/plugins/classes.md | 75 ++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/docs/en/plugins/classes.md b/docs/en/plugins/classes.md index 8c754b5..7bc03d9 100644 --- a/docs/en/plugins/classes.md +++ b/docs/en/plugins/classes.md @@ -199,47 +199,100 @@ _`nick: str` -> Player Nickname - The name of the player._ The method returns a player object by their `pid` or `nick`. -## Player (or Client) +## Player (or Client) _`pl = kt.get_player()`_\ _`pl = event_data['kwargs']['player']`_ ### pl.log -> Logger _Constant_\ -Returns a pre-configured logger +Returns a preconfigured logger. ### pl.addr -> str _Constant_\ -Returns the IP address of the player +Returns the player's IP address. ### pl.pid -> int ### pl.cid -> int _Constant_\ -Returns the client ID _(pid: PlayerId = cid: ClientId)_ +Returns the client ID _(pid: PlayerId = cid: ClientId)_. ### pl.key -> str _Constant_\ -Returns the key passed during authentication +Returns the key passed during authorization. ### pl.nick -> str _Variable_\ -The nickname passed during authentication from the BeamMP server, can be changed, consequences are untested +Nickname passed during authorization from the BeamMP server, can be changed, consequences are not tested. ### pl.roles -> str _Variable_\ -The role passed during authentication from the BeamMP server, can be changed (if an incorrect role is set, unexpected things may happen.) +Role passed during authorization from the BeamMP server, can be changed (If the wrong role is set, unexpected behavior may occur.) ### pl.guest -> bool _Constant_\ -Returns whether the player is a guest, passed during authentication from the BeamMP server +Returns whether the player is a guest, passed during authorization from the BeamMP server. ### pl.identifiers -> dict _Constant_\ -Identifiers passed during authentication from the BeamMP server. +Identifiers passed during authorization from the BeamMP server. ### pl.ready -> bool _Constant, changed by the core_\ -Returns a bool value, if True -> the player has downloaded all resources, loaded on the map +Returns a bool value, if True -> player has downloaded all resources and loaded on the map. ### pl.cars -> dict _Constant, changed by the core_\ -Returns a dictionary of cars like this \ No newline at end of file +Returns a dictionary of cars by type: + +```python +{ + 1: { + "packet": car_packet, + "json": car_json, + "json_ok": bool(car_json), + "snowman": snowman, + "over_spawn": (snowman and allow_snowman) or over_spawn, + "pos": { + "pos":[0,0,0], + "rvel":[0,0,0], + "rot":[0,0,0], + "vel":[0,0,0], + "tim":0, + "ping":0 + } + }, + 2: ... +} +``` +Where `1` - car_id\ +Where `pkt` - Unprocessed packet that came from the client (For very experienced users)\ +Where `json` - Processed packet stored as dict\ +Where `json_ok` - Whether the core was able to process the packet\ +Where `snowman` - Is the car a snowman\ +Where `over_spawn` - Is the car spawned over the limit (Allowed through plugins)\ +Where `pos` - Car position (Passed through UDP) + +### pl.last_position -> dict +_Constant, changed by the core_\ +Returns the player's last position + +### **async** pl.kick([reason: str = "Kicked!"]) -> None +_`reason: str` -> Kick reason. Parameter is optional, by default: `Kicked!`_\ +Kicks the player from the server. + +### **async** pl.send_message(message: str, [to_all: bool = True]) -> None +_`message: str` -> Message text, sent without "Server:"_\ +_`to_all: bool` -> Should this message be sent to everyone? Parameter is optional, by default: `True`_\ +Sends a message to the player or everyone. + +### **async** pl.send_event(event_name: str, event_data: Any, [to_all: bool = True]) -> None +_`event_name: str` -> Name of the event that will be called_\ +_`event_data: Any` -> Data sent to the event._\ +_`to_all: bool` -> Should this message be sent to everyone? Parameter is optional, by default: `True`_\ +Sends an event to the client.\ +If event_data is a tuple, list, dict, then before sending the core converts it to JSON via json.dumps(event_data)\ +Otherwise, the data will be a string without regulation. + +### **async** pl.delete_car(self, car_id: int) -> None +_`car_id: int` -> Car ID_\ +Deletes the player's car.