forked from NoxenScripts/noxen_notify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
57 lines (52 loc) · 1.93 KB
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- Register the event to send a notification to the frontend
RegisterNetEvent('noxen:notify')
AddEventHandler('noxen:notify', function(title, message, type, time, playSound, image)
local title = title or "Notification"
local message = message or "Message"
local type = type or "info"
local time = time or 5000
local playSound = playSound or false
local image = image or false
SendNUIMessage({
action = "notification",
title = title,
message = message,
type = type,
time = time,
playSound = playSound,
image = image
})
end)
-- Command to test the notification system
if Config.CommandTest then
RegisterCommand("notify", function(source, args)
local title = args[1] or "Notification"
local message = args[2] or "Message"
local type = args[3] or "info"
local time = args[4] or 20000
local playSound = args[5] or false
local image = args[6] or false
TriggerEvent('noxen:notify', title, message, type, time, playSound, image)
end, false)
RegisterCommand("notifycolors", function(source, args)
local title = "Notification colors"
local message = "~r~Red~n~~g~Green~n~~b~Blue~n~~y~Yellow~n~~p~Purple~n~~q~Pink~n~~o~Orange~n~~w~White~n~~d~Grey~n~~l~Black~n~~d~Blue-Dark~w~~n~~h~Bold~n~~italic~Italic"
local type = args[1] or "info"
local time = args[2] or 20000
local playSound = args[3] or false
local image = args[4] or false
TriggerEvent('noxen:notify', title, message, type, time, playSound, image)
end, false)
end
--Add fonction initalisation Config LUA
function SendConfigToFrontEnd()
SendNUIMessage({
action = "setConfig",
defaultPosition = Config.Position
})
end
AddEventHandler('onResourceStart', function(resourceName)
if GetCurrentResourceName() ~= resourceName then return end
Wait(500)
SendConfigToFrontEnd()
end)