This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nrzull
committed
Jun 15, 2019
1 parent
f05d0fb
commit 14f2ee7
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
## Description | ||
|
||
This chat is using CEF and it tries to become full replacement for default chat | ||
|
||
## Pros | ||
|
||
- Emojis (😈) | ||
- Adaptive (you don't need to put-on glasses for your 1920x1080 screen to see what others write) | ||
- Copy/paste from/to input (no more console -> say someLongMessageOrUrl) | ||
- Customizable (now you can unify a chat for all of your players) | ||
|
||
## Cons | ||
|
||
- For execution of custom commands resource needs an access right for [ExecuteCommandHandler](https://wiki.multitheftauto.com/wiki/ExecuteCommandHandler) in ACL | ||
- It can't execute built-in commands like `/nick`, `/login`, etc "due to security reasons." (c) mta wiki | ||
- It can't be used until resource starts so you can't write useful messages to player in `onPlayerConnect` event handler | ||
|
||
## API | ||
|
||
### Clientside | ||
|
||
#### Functions | ||
|
||
- **output(string message) -> void** | ||
Writes a message to chat. Hex colors processing is enabled by default and this behavior can't be configured by end-user. | ||
|
||
- **clear() -> void** | ||
Clears all messages. Chat doesn't have history. | ||
|
||
- **isVisible() -> bool** | ||
Returns true/false if chat is visible. | ||
|
||
- **show(bool b) -> void** | ||
Shows/hides a chat. | ||
|
||
### Serverside | ||
|
||
#### Functions | ||
|
||
- **output(element player, string message) -> void** | ||
- **clear(element player) -> void** | ||
- **isVisible(element player) -> bool** | ||
- **show(element player, bool b) -> void** | ||
|
||
#### Events | ||
|
||
- **onPlayerChat2** | ||
handler params: (element player, string message) | ||
Will be emitted only after useDefaultOutput(false) | ||
|
||
### Examples: | ||
|
||
```lua | ||
addEventHandler("onPlayerJoin", root, function() | ||
exports.chat2:output(source, "#ccff00hello from default output #ffcc00chat") | ||
exports.chat2:useDefaultOutput(false) -- disable built-in handler and use own handlers that listen for "onPlayerChat2" event | ||
end) | ||
|
||
addEventHandler("onPlayerChat2", root, function(sender, message) | ||
for _, player in ipairs(getElementsByType("player")) do | ||
local text = string.format("%s wrote: %s", nickname, message) | ||
output(player, text) | ||
end | ||
end) | ||
``` |