-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
61 lines (53 loc) · 1.73 KB
/
client.lua
File metadata and controls
61 lines (53 loc) · 1.73 KB
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
58
59
60
61
RegisterNetEvent('qb-warnings:client:ShowWarnings', function(warnings)
local options = {}
for _, warn in ipairs(warnings) do
local warnId = warn.warnId or "N/A"
table.insert(options, {
title = warn.reason,
description = string.format("ID: %s", warnId),
icon = 'triangle-exclamation',
onSelect = function()
local confirm = lib.alertDialog({
header = 'Delete Warning',
content = 'Would you like to delete this warning?',
centered = true,
cancel = true
})
if confirm == 'confirm' then
TriggerServerEvent('qb-warnings:server:DeleteWarning', warnId)
end
end
})
end
if #options == 0 then
table.insert(options, {
title = "No Warnings Found",
icon = 'circle-check'
})
end
lib.registerContext({
id = 'player_warnings',
title = 'Your Warnings',
options = options
})
lib.showContext('player_warnings')
end)
RegisterNetEvent('qb-warnings:client:NotifyDeleted', function(success)
if success then
lib.notify({
title = 'Warning Deleted',
type = 'success'
})
-- Refresh the menu
TriggerServerEvent('qb-warnings:server:RequestWarnings')
else
lib.notify({
title = 'Permission Denied or Error',
type = 'error'
})
end
end)
-- Request warnings again if deleted
RegisterCommand('warnings', function()
TriggerServerEvent('qb-warnings:server:RequestWarnings')
end, false)