Skip to content

Commit cd232f5

Browse files
committed
Update v2.1.1
* Added MSK.Numpad * Added new Design for MSK.Input * Fixed MSK.Input * Fixed Config.customNotification
1 parent ae90f2e commit cd232f5

File tree

8 files changed

+86
-32
lines changed

8 files changed

+86
-32
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.0
1+
2.1.1

client/cl_input.lua

+29-22
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
local isOpen = false
2-
local callback = {}
1+
local isInputOpen = false
2+
local callback = nil
33

4-
openInput = function(header, placeholder, field, cb)
5-
if isOpen then return print('Input is already open') end
6-
if not cb then callback = field else callback = cb end
4+
MSK.Input = function(header, placeholder, field, cb)
5+
if isInputOpen then return end
6+
logging('debug', 'MSK.Input')
7+
isInputOpen = true
8+
callback = cb
9+
if not callback then callback = field end
710

811
SetNuiFocus(true, true)
912
SendNUIMessage({
@@ -12,30 +15,34 @@ openInput = function(header, placeholder, field, cb)
1215
placeholder = placeholder,
1316
field = field and type(field) == 'boolean'
1417
})
15-
isOpen = true
1618
end
17-
MSK.Input = openInput
18-
exports('openInput', openInput)
19+
exports('Input', MSK.Input)
20+
exports('openInput', MSK.Input)
1921

20-
closeInput = function()
22+
MSK.CloseInput = function()
23+
logging('debug', 'MSK.CloseInput')
24+
isInputOpen = false
25+
callback = nil
2126
SetNuiFocus(false, false)
22-
isOpen = false
27+
SendNUIMessage({
28+
action = 'closeInput'
29+
})
2330
end
24-
MSK.CloseInput = closeInput
25-
exports('closeInput', closeInput)
26-
27-
RegisterNUICallback('closeInput', function(data)
28-
callback()
29-
closeInput()
30-
end)
31+
exports('CloseInput', MSK.CloseInput)
32+
exports('closeInput', MSK.CloseInput)
3133

3234
RegisterNUICallback('submitInput', function(data)
35+
if data.input == '' then data.input = nil end
36+
if tonumber(data.input) then data.input = tonumber(data.input) end
3337
callback(data.input)
34-
closeInput()
38+
MSK.CloseInput()
39+
end)
40+
41+
RegisterNUICallback('closeInput', function(data)
42+
MSK.CloseInput()
3543
end)
3644

37-
AddEventHandler('onResourceStop', function(resourceName)
38-
if resourceName == GetCurrentResourceName() then
39-
closeInput()
40-
end
45+
AddEventHandler('onResourceStop', function(resource)
46+
if GetCurrentResourceName() ~= resource then return end
47+
MSK.CloseInput()
4148
end)

client/cl_numpad.lua

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
local isNumpadOpen = false
2+
local callback = nil
3+
4+
MSK.Numpad = function(pin, show, cb)
5+
if isNumpadOpen then return end
6+
logging('debug', 'MSK.Numpad')
7+
isNumpadOpen = true
8+
callback = cb
9+
10+
SetNuiFocus(true, true)
11+
SendNUIMessage({
12+
action = 'openNumpad',
13+
code = tostring(pin),
14+
length = string.len(tostring(pin)),
15+
show = show,
16+
EnterCode = 'Enter Code',
17+
WrongCode = 'Incorrect',
18+
})
19+
end
20+
exports('Numpad', MSK.Numpad)
21+
22+
MSK.CloseNumpad = function()
23+
logging('debug', 'MSK.CloseNumpad')
24+
isNumpadOpen = false
25+
callback = nil
26+
SetNuiFocus(false, false)
27+
SendNUIMessage({
28+
action = 'closeNumpad'
29+
})
30+
end
31+
exports('CloseNumpad', MSK.CloseNumpad)
32+
33+
RegisterNUICallback('submitNumpad', function(data)
34+
callback(true)
35+
MSK.CloseNumpad()
36+
end)
37+
38+
RegisterNUICallback('closeNumpad', function()
39+
MSK.CloseNumpad()
40+
end)
41+
42+
AddEventHandler('onResourceStop', function(resource)
43+
if GetCurrentResourceName() ~= resource then return end
44+
MSK.CloseNumpad()
45+
end)
46+

client/cl_progress.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
ProgressStart = function(time, text, color)
1+
MSK.Progressbar = function(time, text, color)
22
SendNUIMessage({
33
action = 'progressBarStart',
44
time = time,
55
text = text or '',
66
color = color or Config.progressColor,
77
})
88
end
9-
MSK.ProgressStart = ProgressStart
10-
exports('ProgressStart', ProgressStart)
9+
MSK.ProgressStart = MSK.Progressbar
10+
exports('Progressbar', MSK.Progressbar)
11+
exports('ProgressStart', MSK.Progressbar)
1112

12-
ProgressStop = function()
13+
MSK.ProgressStop = function()
1314
SendNUIMessage({
1415
action = 'progressBarStop',
1516
})
1617
end
17-
MSK.ProgressStop = ProgressStop
18-
exports('ProgressStop', ProgressStop)
18+
exports('ProgressStop', MSK.ProgressStop)

client/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ MSK.Notification = function(title, message, info, time)
4141
elseif Config.Notification == 'okok' then
4242
exports['okokNotify']:Alert(title, message, time or 5000, info or 'info')
4343
elseif Config.Notification == 'custom' then
44-
Config.customNotification()
44+
Config.customNotification(title, message, info, time)
4545
else
4646
SendNUIMessage({
4747
action = 'notify',

common/common.lua

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ MSK.Logging = function(code, ...)
115115
local script = "[^2"..GetInvokingResource().."^0]"
116116

117117
if not MSK.TableContains({'error', 'debug', 'info'}, code) then
118+
-- Support for old Scripts
118119
script = code
119120
local action = ...
120121
local args = {...}

config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Config.showCoords = {
1919
-- Set to 'custom' for Config.customNotification()
2020
Config.Notification = 'msk'
2121

22-
Config.customNotification = function()
22+
Config.customNotification = function(title, message, info, time)
2323
-- Set Config.Notification = 'custom'
2424
-- Add your own clientside Notification here
2525
end

fxmanifest.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ games { 'gta5' }
44
author 'Musiker15 - MSK Scripts'
55
name 'msk_core'
66
description 'Core functions for MSK Scripts'
7-
version '2.1.0'
7+
version '2.1.1'
88

99
lua54 'yes'
1010

0 commit comments

Comments
 (0)