-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.lua
83 lines (75 loc) · 2.31 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
lib.locale()
RegisterNetEvent('door_lockdown:receiveDoors')
AddEventHandler('door_lockdown:receiveDoors', function(doorlocks)
local options = {}
for _, door in ipairs(doorlocks) do
local doorData = json.decode(door.data)
local lockState = doorData.state == 1 and locale('locked') or locale('unlocked')
local passcode = doorData.passcode
local label = ''
if doorData.passcode then
label = string.format("%s (%d, %s, %s)", door.name, door.id, passcode, lockState)
else
label = string.format("%s (%d, %s)", door.name, door.id, lockState)
end
table.insert(options, {
label = label,
value = door.id
})
end
local input = lib.inputDialog(locale('input_title'), {
{
type = 'checkbox',
label = locale('all_doors'),
},
{
type = 'multi-select',
name = 'selectedDoors',
label = locale('selected_doors'),
options = options
},
{
type = 'select',
name = 'action',
label = locale('action'),
options = {
{label = locale('lock'), value = 'lock'},
{label = locale('unlock'), value = 'unlock'}
}
}
})
if not input then
return
end
local allDoors = input[1]
local selectedDoors = input[2]
local action = input[3]
if allDoors or #selectedDoors > 0 then
if allDoors then
selectedDoors = {}
for _, door in ipairs(doorlocks) do
table.insert(selectedDoors, door.id)
end
end
if action == 'lock' then
TriggerServerEvent('door_lockdown:lockdown', selectedDoors)
lib.notify(
{
type = 'success',
title = locale('lockdown_notification_title'),
}
)
else
TriggerServerEvent('door_lockdown:unlock', selectedDoors)
lib.notify(
{
type = 'success',
title = locale('unlock_notification_title'),
}
)
end
end
end)
RegisterCommand('doors', function()
TriggerServerEvent('door_lockdown:getAllDoors')
end)