7.8 KiB
Sure, here's a translation of the text:
Passed Classes
Worth looking at
- What are
*args
and**kwargs
? -> Post on Habr (RU)
KuiToi
kt = KuiToi("PluginName"")
kt.log
Constant
Returns a pre-configured logger
kt.name
Constant
Returns the name of the plugin
kt.dir
Constant
Returns the directory of the plugin
kt.open()
Parameters are the same as for open()
Opens a file in kt.dir
kt.register_event(event_name: str, event_func: function)
event_name: str
-> The name of the event that event_func
will be called on.
event_func: function
-> The function that will be called.
In event_func
, you can pass both regular functions and async functions - you don't need to make them async beforehand.
You can also create your own events with your own names.
You can register an unlimited number of events.
kt.call_event(event_name: str, *args, **kwargs) -> list:
event_name: str
-> The name of the event to call.
*args, **kwargs
-> Arguments to be passed to the function.
async kt.call_async_event(event_name: str, *args, **kwargs) -> list:
event_name: str
-> The name of the event to call.
*args, **kwargs
-> Arguments to be passed to the function.
Must be called with await
I recommend familiarizing yourself with *args, **kwargs, there is a link at the beginning
Data is passed to all events in the form of: {"event_name": event_name, "args": args, "kwargs": kwargs}
args: list
-> Represents an array of data passed to the event
kwargs: dict
-> Represents a dictionary of data passed to the event
The data will be returned from all successful attempts in an array.
kt.call_lua_event(event_name: str, *args) -> list:
event_name: str
-> The name of the event to call.
*args
-> Arguments to be passed to the function.
Added to support backward compatibility.
The lua function is called with a direct transmission of arguments lua_func(*args)
kt.get_player([pid: int], [nick: str]) -> Player | None:
pid: int
-> Player ID - The identifier of the player.
nick: str
-> Player Nickname - The name of the player.
The method returns a player object by their pid
or nick
.
If the player cannot be found, None
will be returned.
kt.get_players() -> List[Player] | list:
The method returns an array with all players.
The array will be empty if there are no players.
kt.players_counter() -> int:
The method returns the number of players currently online.
kt.is_player_connected([pid: int], [nick: str]) -> bool:
pid: int
-> Player ID - The identifier of the player.
nick: str
-> Player Nickname - The name of the player.
The method returns a player object by their pid
or nick
.
Player (or Client)
pl = kt.get_player()
pl = event_data['kwargs']['player']
pl.log -> Logger
Constant
Returns a pre-configured logger
pl.addr -> str
Constant
Returns the IP address of the player
pl.pid -> int
pl.cid -> int
Constant
Returns the client ID (pid: PlayerId = cid: ClientId)
pl.key -> str
Constant
Returns the key passed during authentication
pl.nick -> str
Variable
The nickname passed during authentication from the BeamMP server, can be changed, consequences are untested
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.)
pl.guest -> bool
Constant
Returns whether the player is a guest, passed during authentication from the BeamMP server
pl.identifiers -> dict
Constant
Identifiers passed during authentication 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
pl.cars -> dict
Constant, changed by the core
Returns a dictionary of cars like thisSure, here's the translation:
Passed Classes
Worth looking at
- What are
*args
and**kwargs
? -> Post on Habr ↗
KuiToi
kt = KuiToi("PluginName"")
kt.log
Constant
Returns a pre-configured logger
kt.name
Constant
Returns the name of the plugin
kt.dir
Constant
Returns the directory of the plugin
kt.open()
Parameters are the same as for open()
Opens a file in kt.dir
kt.register_event(event_name: str, event_func: function)
event_name: str
-> The name of the event that event_func
will be called on.
event_func: function
-> The function that will be called.
In event_func
, you can pass both regular functions and async functions - you don't need to make them async beforehand.
You can also create your own events with your own names.
You can register an unlimited number of events.
kt.call_event(event_name: str, *args, **kwargs) -> list:
event_name: str
-> The name of the event to call.
*args, **kwargs
-> Arguments to be passed to the function.
async kt.call_async_event(event_name: str, *args, **kwargs) -> list:
event_name: str
-> The name of the event to call.
*args, **kwargs
-> Arguments to be passed to the function.
Must be called with await
I recommend familiarizing yourself with *args, **kwargs, there is a link at the beginning
Data is passed to all events in the form of: {"event_name": event_name, "args": args, "kwargs": kwargs}
args: list
-> Represents an array of data passed to the event
kwargs: dict
-> Represents a dictionary of data passed to the event
The data will be returned from all successful attempts in an array.
kt.call_lua_event(event_name: str, *args) -> list:
event_name: str
-> The name of the event to call.
*args
-> Arguments to be passed to the function.
Added to support backward compatibility.
The lua function is called with a direct transmission of arguments lua_func(*args)
kt.get_player([pid: int], [nick: str]) -> Player | None:
pid: int
-> Player ID - The identifier of the player.
nick: str
-> Player Nickname - The name of the player.
The method returns a player object by their pid
or nick
.
If the player cannot be found, None
will be returned.
kt.get_players() -> List[Player] | list:
The method returns an array with all players.
The array will be empty if there are no players.
kt.players_counter() -> int:
The method returns the number of players currently online.
kt.is_player_connected([pid: int], [nick: str]) -> bool:
pid: int
-> Player ID - The identifier of the player.
nick: str
-> Player Nickname - The name of the player.
The method returns a player object by their pid
or nick
.
Player (or Client)
pl = kt.get_player()
pl = event_data['kwargs']['player']
pl.log -> Logger
Constant
Returns a pre-configured logger
pl.addr -> str
Constant
Returns the IP address of the player
pl.pid -> int
pl.cid -> int
Constant
Returns the client ID (pid: PlayerId = cid: ClientId)
pl.key -> str
Constant
Returns the key passed during authentication
pl.nick -> str
Variable
The nickname passed during authentication from the BeamMP server, can be changed, consequences are untested
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.)
pl.guest -> bool
Constant
Returns whether the player is a guest, passed during authentication from the BeamMP server
pl.identifiers -> dict
Constant
Identifiers passed during authentication 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
pl.cars -> dict
Constant, changed by the core
Returns a dictionary of cars like this