-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from esx-framework/revert-96-fix/xplayer-show…
…notification Revert "fix(server/xPlayer/showNotification): Fix showNotification function parameters to correspond with esx:showNotification event"
- Loading branch information
Showing
1 changed file
with
28 additions
and
31 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 |
---|---|---|
@@ -1,49 +1,46 @@ | ||
# showNotification | ||
|
||
```lua | ||
xPlayer.showNotification(msg, type, length) | ||
xPlayer.showNotification(msg, flash, saveToBrief, hudColorIndex) | ||
``` | ||
|
||
## Color Codes | ||
|
||
```lua | ||
~r~ = Red | ||
~b~ = Blue | ||
~g~ = Green | ||
~y~ = Yellow | ||
~p~ = Purple | ||
~c~ = Grey | ||
~m~ = Dark Grey | ||
~u~ = Black | ||
~o~ = Orange | ||
``` | ||
|
||
This function shows a notification to the player. | ||
|
||
## String Types | ||
|
||
| Syntax | Types | | ||
| --------- | -------------------- | | ||
| "info" | Info Notification | | ||
| "success" | Success Notification | | ||
| "error" | Error Notification | | ||
This function shows a basic notification to the player. | ||
|
||
## String Colors | ||
|
||
| Syntax | Color | | ||
| ------ | --------------- | | ||
| ~r~ | Red | | ||
| ~b~ | Blue | | ||
| ~g~ | Green | | ||
| ~y~ | Yellow | | ||
| ~p~ | Purple | | ||
| ~o~ | Orange | | ||
| ~c~ | Grey | | ||
| ~m~ | Dark Grey | | ||
| ~u~ | Black | | ||
| ~n~ | New Line | | ||
| ~s~ | White (default) | | ||
| ~w~ | White | | ||
| ~h~ | Toggle Bold | | ||
|
||
## Arguments | ||
|
||
| Argument | Data Type | Optional | Default Value | Explanation | | ||
| -------- | --------- | -------- | ------------- | ----------------------------------------- | | ||
| msg | string | No | - | The message to display | | ||
| Type | string | Yes | "info" | What type the notification would be | | ||
| time | number | Yes | 3000 | For how long the notification should show | | ||
| Argument | Data Type | Optional | Default Value | Explanation | | ||
| ------------- | --------- | -------- | ------------- | --------------------------------------------------------------------------------------------------- | | ||
| msg | string | No | - | The message to display | | ||
| flash | boolean | Yes | false | Flash the notification? | | ||
| saveToBreif | boolean | Yes | true | Save to breif? Located in Pause Menu > Help | | ||
| hudColorIndex | number | Yes | nil | The background color, see <https://gyazo.com/68bd384455fceb0a85a8729e48216e15> for available colors | | ||
|
||
## Example | ||
|
||
```lua | ||
local xPlayer = ESX.GetPlayerFromId(source) | ||
local breadCount = xPlayer.getInventoryItem('bread').count -- how much bread the player has | ||
if breadCount > 1 then -- checks if they have more than 1 bread | ||
xPlayer.showNotification('Congrats!, you have '.. breadCount .. ' Bread!', 'success', 5000) -- send them a happy message, telling them how much bread they have | ||
xPlayer.showNotification('Congrats!, you have '.. breadCount .. ' Bread!') -- send them a happy message, telling them how much bread they have | ||
else -- if they have no bread | ||
xPlayer.showNotification('oh no! you have no bread!', 'error') -- send them a sad message expressing your disapointment | ||
xPlayer.showNotification('oh no! you have no bread!') -- send them a sad message expressing your disapointment | ||
end | ||
``` |