Files
esx_core/[esx]/esx_textui/TextUI.lua
T
2022-11-26 17:16:19 +00:00

46 lines
1.0 KiB
Lua

Debug = ESX.GetConfig().EnableDebug
local IsShowing = false
---@param message string
---@param Type string
local function TextUI(message, type)
IsShowing = true
SendNUIMessage({
action = 'show',
message = message and message or 'ESX-TextUI',
type = type == 0 and "info" or type
})
end
local function HideUI()
if not IsShowing then
return
end
IsShowing = false
SendNUIMessage({
action = 'hide'
})
end
exports('TextUI', TextUI)
exports('HideUI', HideUI)
RegisterNetEvent('ESX:TextUI', TextUI)
RegisterNetEvent('ESX:HideUI', HideUI)
if Debug then
RegisterCommand("textui:error", function()
ESX.TextUI("i ~r~love~s~ donuts", "error")
end)
RegisterCommand("textui:success", function()
ESX.TextUI("i ~g~love~s~ donuts", "success")
end)
RegisterCommand("textui:info", function()
ESX.TextUI("i ~b~love~s~ donuts", "info")
end)
RegisterCommand("textui:hide", function()
ESX.HideUI()
end)
end