-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient.lua
More file actions
118 lines (104 loc) · 3.56 KB
/
client.lua
File metadata and controls
118 lines (104 loc) · 3.56 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
local menuItems = {
{
label = 'Clothing',
icon = 'fa-solid fa-shirt',
items = {
{ label = 'Hat', icon = 'fa-solid fa-hat-cowboy', event = ''},
{ label = 'Glasses', icon = 'fa-solid fa-glasses', event = ''},
{ label = 'Mask', icon = 'fa-solid fa-mask', event = ''},
{ label = 'Shirt', icon = 'fa-solid fa-shirt', event = ''},
{ label = 'Pant', icon = 'fa-solid fa-person-walking', event = ''},
{ label = 'Shoes', icon = 'fa-solid fa-shoe-prints', event = ''},
},
shouldclose = false
},
{ label = 'Trunk', icon = 'fa-solid fa-car', event = 'qb-trunk:client:GetIn', shouldclose = true},
{ label = 'Escort', icon = 'fa-solid fa-user-group', event = '', shouldclose = true},
{ label = 'Share Contact', icon = 'fa-solid fa-phone', event = '', shouldclose = true},
{ label = 'Walk Styles', icon = 'fa-solid fa-person-walking', event = '', shouldclose = true},
}
local isMenuVisible = false
local toggleCooldown = false
local function toggleMenu()
if toggleCooldown then return end
toggleCooldown = true
if not isMenuVisible then
PlaySoundFrontend(-1, "NAV", "HUD_AMMO_SHOP_SOUNDSET", 1)
isMenuVisible = true
SetNuiFocus(true, true)
SetNuiFocusKeepInput(true)
SendNUIMessage({
action = 'updateMenuItems',
items = menuItems
})
else
SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
isMenuVisible = false
SendNUIMessage({
action = 'closeMenu'
})
end
SetTimeout(1000, function()
toggleCooldown = false
end)
end
RegisterCommand('togglemenu', function()
toggleMenu()
end, false)
RegisterKeyMapping('togglemenu', 'Toggle Radial Menu', 'keyboard', 'F1')
RegisterNUICallback('menuItemClicked', function(data, cb)
local label = data.label
local selectedItem = nil
-- Find the clicked item
for _, item in ipairs(menuItems) do
if item.label == label then
selectedItem = item
break
end
end
if selectedItem then
if selectedItem.items and #selectedItem.items > 0 then
SendNUIMessage({
action = 'updateMenuItems',
items = selectedItem.items
})
else
if selectedItem.event and selectedItem.event ~= '' then
TriggerEvent(selectedItem.event)
end
if selectedItem.shouldclose then
SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
isMenuVisible = false
SendNUIMessage({
action = 'closeMenu'
})
end
end
cb('ok')
else
cb('error')
end
end)
RegisterNUICallback('closemenu', function(data, cb)
PlaySoundFrontend(-1, "NAV", "HUD_AMMO_SHOP_SOUNDSET", 1)
SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
isMenuVisible = false
SendNUIMessage({ action = 'closeMenu' })
cb('ok')
end)
CreateThread(function ()
while true do
if isMenuVisible then
DisablePlayerFiring(PlayerPedId(), true)
DisableControlAction(0, 1, true)
DisableControlAction(0, 2, true)
DisableControlAction(0, 142, true)
DisableControlAction(2, 199, true)
DisableControlAction(2, 200, true)
end
Wait(5)
end
end)