52 lines
1.8 KiB
Lua
52 lines
1.8 KiB
Lua
-- IsDuplicityVersion - is used to determine if the function is called by the server or the client (true == from server)
|
|
|
|
--------------------- SHARED FUNCTIONS ---------------------
|
|
local Core = nil
|
|
--- @return table Core The core object of the framework
|
|
function GetCoreObject()
|
|
if not Core then
|
|
if Config.Framework == "esx" then
|
|
Core = exports["es_extended"]:getSharedObject()
|
|
elseif Config.Framework == "qb" or Config.Framework == "qbx" then
|
|
Core = exports["qb-core"]:GetCoreObject()
|
|
end
|
|
end
|
|
return Core
|
|
end
|
|
|
|
Core = Config.Framework ~= "none" and GetCoreObject() or nil
|
|
|
|
--- @param text string The text to show in the notification
|
|
--- @param notificationType string The type of notification to show ex: 'success', 'error', 'info'
|
|
--- @param src - number|nil The source of the player - only required when called from server side
|
|
function Notify(text, notificationType, src)
|
|
if IsDuplicityVersion() then
|
|
if Config.Notify == "esx" then
|
|
TriggerClientEvent("esx:showNotification", src, text)
|
|
elseif Config.Notify == "qb" then
|
|
TriggerClientEvent("QBCore:Notify", src, text, notificationType)
|
|
elseif Config.Notify == "ox" then
|
|
TriggerClientEvent("ox_lib:notify", src, {
|
|
description = text,
|
|
type = notificationType,
|
|
})
|
|
end
|
|
else
|
|
if Config.Notify == "esx" then
|
|
Core.ShowNotification(text)
|
|
elseif Config.Notify == "qb" then
|
|
Core.Functions.Notify(text, notificationType)
|
|
elseif Config.Notify == "ox" then
|
|
lib.notify({
|
|
description = text,
|
|
type = notificationType,
|
|
})
|
|
end
|
|
end
|
|
end
|
|
|
|
--------------------- CLIENT FUNCTIONS ---------------------
|
|
|
|
|
|
--------------------- SERVER FUNCTIONS ---------------------
|