Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix(server/xPlayer/showNotification): Fix showNotification function parameters to correspond with esx:showNotification event" #106

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 28 additions & 31 deletions docs/legacy/Server/xplayer/shownotification.md
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
```
Loading