-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient.lua
More file actions
93 lines (77 loc) · 2.3 KB
/
Copy pathclient.lua
File metadata and controls
93 lines (77 loc) · 2.3 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
local isOpened = false
local nuiReady = false
local function generateKeybindName(baseName)
return string.format('%s-%s-%s', GetCurrentResourceName(), baseName, GetGameTimer())
end
local function addKeybind(params)
local name, description, defaultKey, onPressed in params
local keybindName = generateKeybindName(name)
RegisterCommand(name, onPressed, false)
RegisterKeyMapping(name, description, 'KEYBOARD', defaultKey)
end
local function sendNui(action, data)
local messageData = { action = tostring(action) }
if data then
for k, v in pairs(data) do
messageData[k] = v
end
end
SendNUIMessage(messageData)
end
local function startBlockNuiControls()
CreateThread(function()
while isOpened do
DisableControlAction(0, 200, true) -- Pause Menu
DisableControlAction(0, 199, true) -- Map
if GetPauseMenuState() > 0 then
SetFrontendActive(false)
end
Wait(0)
end
end)
end
local function onPauseMenuKeyPressed()
if not nuiReady then return end
if not IsPauseMenuActive() and not IsNuiFocused() then
isOpened = true
startBlockNuiControls()
sendNui('openEsc')
SetNuiFocus(true, true)
SetCursorLocation(0.15, 0.75)
end
end
addKeybind({
name = 'pausemenu',
description = 'Pause Menu',
defaultKey = 'ESCAPE',
onPressed = onPauseMenuKeyPressed
})
RegisterNUICallback('SendAction', function(data)
SetNuiFocus(false, false)
local actionHandlers = {
exit = function()
isOpened = false
end,
settings = function()
ActivateFrontendMenu(GetHashKey('FE_MENU_VERSION_LANDING_MENU'), 0, -1)
end,
map = function()
ActivateFrontendMenu('FE_MENU_VERSION_MP_PAUSE', false, -1)
end
}
local actionHandler = actionHandlers[data.action]
if actionHandler then
actionHandler()
end
end)
CreateThread(function()
Wait(500)
sendNui('setup', {
translatedTbl = Config.Translations[Config.Locale],
serverIcon = Config.SERVER_ICON
})
nuiReady = true
end)
exports('isOpen', function()
return isOpened
end)