Skip to main content

showNotification

xPlayer.showNotification(msg, flash, saveToBrief, hudColorIndex)

This function shows a basic notification to the player.

String Colors

SyntaxColor
~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

ArgumentData TypeOptionalDefault ValueExplanation
msgstringNo-The message to display
flashbooleanYesfalseFlash the notification?
saveToBreifbooleanYestrueSave to breif? Located in Pause Menu > Help
hudColorIndexnumberYesnilThe background color, see https://gyazo.com/68bd384455fceb0a85a8729e48216e15 for available colors

Example

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!') -- 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!') -- send them a sad message expressing your disapointment
end