update doc/*/scripting/events.md

This commit is contained in:
MihailRis
2024-11-01 15:14:25 +03:00
parent 72d5eca632
commit a47bdc0409
2 changed files with 42 additions and 0 deletions
+21
View File
@@ -136,3 +136,24 @@ function on_hud_close(playerid: int)
```
Called on world close (before saving)
## *events* library
```lua
events.on(code: str, handler: function)
```
Adds an event handler by its code, not limited to the standard ones.
```lua
events.emit(code: str, args...) -> bool
```
Emits an event by code. If the event does not exist, nothing will happen.
The existence of an event is determined by the presence of handlers.
```lua
events.unload(packid: str)
```
Removes all events with the prefix `packid:`. When you exit the world, events from all packs are unloaded, including `core:`.