Skip to content

Commit 7f0f7e2

Browse files
committed
Update v2.7.0
1 parent 1827f65 commit 7f0f7e2

File tree

12 files changed

+319
-29
lines changed

12 files changed

+319
-29
lines changed

client/functions/progressbar.lua

+12-8
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ MSK.Progress.Start = function(data, text, color)
9999
if type(data) == 'table' then
100100
duration = data.duration
101101
text = data.text
102-
color = data.color or Config.progressColor
102+
color = data.color or Config.ProgressColor or Config.progressColor
103103
forceOverride = data.forceOverride or forceOverride
104104
end
105105

@@ -111,20 +111,20 @@ MSK.Progress.Start = function(data, text, color)
111111
action = 'progressBarStart',
112112
time = duration,
113113
text = text or '',
114-
color = color or Config.progressColor,
114+
color = color or Config.ProgressColor or Config.progressColor,
115115
})
116116

117117
if type(data) == 'table' then
118118
return setProgressData(data)
119119
end
120120
end
121-
MSK.Progressbar = MSK.Progress.Start -- Support for old Scripts
121+
MSK.Progressbar = MSK.Progress.Start -- Backwards compatibility
122122
exports('Progressbar', MSK.Progress.Start)
123123
RegisterNetEvent("msk_core:progressbar", MSK.Progress.Start)
124124

125125
setmetatable(MSK.Progress, {
126-
__call = function(self, data, text, color)
127-
self.Start(data, text, color)
126+
__call = function(self, ...)
127+
self.Start(...)
128128
end
129129
})
130130

@@ -138,8 +138,7 @@ MSK.Progress.Stop = function()
138138
isProgressActive = false
139139
progressData = nil
140140
end
141-
MSK.ProgressStop = MSK.Progress.Stop -- Support for old Scripts
142-
exports('ProgressStop', MSK.Progress.Stop) -- Support for old Scripts
141+
MSK.ProgressStop = MSK.Progress.Stop -- Backwards compatibility
143142
RegisterNetEvent("msk_core:progressbarStop", MSK.Progress.Stop)
144143

145144
MSK.Progress.Active = function()
@@ -158,4 +157,9 @@ RegisterCommand('stopProgress', function()
158157
end
159158
end)
160159
RegisterKeyMapping('stopProgress', 'Cancel Progressbar', 'keyboard', 'X')
161-
TriggerEvent('chat:removeSuggestion', '/stopProgress')
160+
TriggerEvent('chat:removeSuggestion', '/stopProgress')
161+
162+
AddEventHandler('onResourceStop', function(resource)
163+
if GetCurrentResourceName() ~= resource then return end
164+
MSK.Progress.Stop()
165+
end)

client/functions/textui.lua

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
MSK.TextUI = {}
2+
3+
local isTextUIOpen = false
4+
local thread = false
5+
6+
MSK.TextUI.Show = function(key, text, color)
7+
if isTextUIOpen then return end
8+
isTextUIOpen = true
9+
10+
SendNUIMessage({
11+
action = 'textUI',
12+
show = true,
13+
key = key or 'E',
14+
text = text or '',
15+
color = color or Config.TextUIColor,
16+
})
17+
end
18+
exports('ShowTextUI', MSK.TextUI.Show)
19+
RegisterNetEvent("msk_core:textUiShow", MSK.TextUI.Show)
20+
21+
setmetatable(MSK.TextUI, {
22+
__call = function(self, ...)
23+
self.Show(...)
24+
end
25+
})
26+
27+
MSK.TextUI.ShowThread = function(key, text, color)
28+
MSK.TextUI.Show(key, text, color)
29+
30+
if thread then return end
31+
thread = true
32+
33+
local timer = GetGameTimer()
34+
CreateThread(function()
35+
while timer + 100 >= GetGameTimer() do Wait(100) end
36+
thread = false
37+
Wait(0)
38+
39+
if not thread then
40+
MSK.TextUI.Hide()
41+
end
42+
end)
43+
end
44+
exports('ShowTextUIThread', MSK.TextUI.ShowThread)
45+
RegisterNetEvent("msk_core:textUiShowThread", MSK.TextUI.ShowThread)
46+
47+
MSK.TextUI.Hide = function()
48+
if not isTextUIOpen then return end
49+
isTextUIOpen = false
50+
thread = false
51+
52+
SendNUIMessage({
53+
action = 'textUI',
54+
show = false
55+
})
56+
end
57+
exports('HideTextUI', MSK.TextUI.Hide)
58+
RegisterNetEvent("msk_core:textUiHide", MSK.TextUI.Hide)
59+
60+
MSK.TextUI.Active = function()
61+
return isTextUIOpen
62+
end
63+
exports('TextUIActive', MSK.TextUI.Active)
64+
65+
AddEventHandler('onResourceStop', function(resource)
66+
if GetCurrentResourceName() ~= resource then return end
67+
MSK.TextUI.Hide()
68+
end)

config.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ Config.customNotification = function(title, message, typ, duration)
4747
-- Add your own clientside Notification here
4848
end
4949
----------------------------------------------------------------
50-
Config.progressColor = "#5eb131" -- Default Color for ProgressBar
50+
Config.ProgressColor = "#5eb131" -- Default Color for ProgressBar
51+
Config.TextUIColor = "#5eb131" -- Default Color for TextUI
5152
----------------------------------------------------------------
5253
Config.LoggingTypes = {
5354
['debug'] = '[^3DEBUG^0]',

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 'Functions for MSK Scripts'
7-
version '2.6.8'
7+
version '2.7.0'
88

99
lua54 'yes'
1010

html/css/import.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
@import url("notify.css");
33
@import url("numpad.css");
44
@import url("progressbar.css");
5-
@import url("input.css");
5+
@import url("input.css");
6+
@import url("textui.css");

html/css/textui.css

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.textui {
2+
position: absolute;
3+
bottom:6vh;
4+
left:50%;
5+
transform:translateX(-50%);
6+
}
7+
8+
.textui-key {
9+
position: relative;
10+
width: 4vh;
11+
height:4vh;
12+
line-height:4vh;
13+
left:50%;
14+
font-size:2vh;
15+
font-weight:bold;
16+
color:white;
17+
text-align:center;
18+
transform:translateX(-50%);
19+
transition: 200ms;
20+
background: repeating-linear-gradient(
21+
-55deg,
22+
rgb(24, 198, 0),
23+
rgb(24, 198, 0) 0.6vh,
24+
rgb(18, 158, 0) 0.6vh,
25+
rgb(18, 158, 0) 1.6vh
26+
);
27+
border-radius:0.4vh;
28+
outline:0.2vh solid rgb(30, 255, 0);
29+
box-shadow:0 1.2vh 2vh rgb(30, 255, 0);
30+
animation:moveLines 2s infinite;
31+
margin-bottom:2vh;
32+
}
33+
34+
@keyframes moveLines {
35+
0% {
36+
/* opacity:1.0; */
37+
background-position-x: 6vh;
38+
margin-bottom:1.6vh;
39+
}
40+
50% {
41+
/* opacity:0.4; */
42+
margin-bottom:3.0vh;
43+
}
44+
100% {
45+
/* opacity:1.0; */
46+
background-position-x: 2vh;
47+
margin-bottom:1.6vh;
48+
}
49+
}
50+
51+
.textui-text {
52+
position: relative;
53+
max-width:30vh;
54+
font-size:2vh;
55+
/* color:rgb(204, 204, 204); */
56+
color:rgb(255, 255, 255);
57+
font-weight:600;
58+
text-align: center;
59+
60+
text-shadow:0vh 0vh 0.5vh black;
61+
}

html/index.html

+6
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,11 @@
7070
<button class="numpad-pin-button numpad-submit-button" id='numpad-submit' onclick="submitNumpad()"><span class="white-mask"><i class="fa-solid fa-check"></i></span></button>
7171
</div>
7272
</div>
73+
74+
<!-- MSK Textui -->
75+
<div class="textui" style="display:none">
76+
<div class="textui-key">E</div>
77+
<div class="textui-text">Drücke E um zu interagieren</div>
78+
</div>
7379
</body>
7480
</html>

html/script.js

+67
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ $(document).ready(function() {
5050
closeNumpad();
5151
} else if (data.action == 'copyCoords') {
5252
copyCoords(data.value);
53+
} else if (data.action == "textUI") {
54+
toggleTextui(data)
5355
}
5456
})
5557
})
@@ -92,6 +94,7 @@ const colors = {
9294
"~r~": "red",
9395
"~b~": "#378cbf",
9496
"~g~": "green",
97+
"~lg~": "#5eb131",
9598
"~y~": "yellow",
9699
"~p~": "purple",
97100
"~c~": "grey",
@@ -293,4 +296,68 @@ submitNumpad = () => {
293296
$('#numpad-display').text(numpadWrongCode)
294297
numpadInput = ''
295298
}
299+
}
300+
301+
/* ----------------
302+
MSK Textui
303+
---------------- */
304+
305+
convertHexToRgbA = (hexVal, alpha) => {
306+
let ret;
307+
308+
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hexVal)) {
309+
ret = hexVal.slice(1);
310+
ret = ret.split('');
311+
312+
if (ret.length == 3) {
313+
let ar = [];
314+
ar.push(ret[0]);
315+
ar.push(ret[0]);
316+
ar.push(ret[1]);
317+
ar.push(ret[1]);
318+
ar.push(ret[2]);
319+
ar.push(ret[2]);
320+
ret = ar;
321+
}
322+
323+
ret = '0x' + ret.join('');
324+
325+
let r = (ret >> 16) & 255;
326+
let g = (ret >> 8) & 255;
327+
let b = ret & 255;
328+
329+
return 'rgba(' + [r, g, b, alpha || 1].join(',') + ')';
330+
}
331+
}
332+
333+
toggleTextui = (data) => {
334+
if (data.show) {
335+
const primaryColor = convertHexToRgbA(data.color, 0.8)
336+
const secondaryColor = convertHexToRgbA(data.color, 0.68)
337+
let text = data.text
338+
339+
for (color in colors) {
340+
if (text.includes(color)) {
341+
let obj = {};
342+
343+
obj[color] = `<span style='color: ${colors[color]}'>`;
344+
obj['~s~'] = '</span>';
345+
346+
text = replaceColors(text, obj);
347+
}
348+
}
349+
350+
$(".textui-key").text(data.key)
351+
$(".textui-text").html(text)
352+
353+
$(".textui-key").css({
354+
background:`repeating-linear-gradient(-55deg, ${primaryColor}, ${primaryColor} 0.8vh, ${secondaryColor} 0.8vh, ${secondaryColor} 1.6vh )`,
355+
outlineColor:data.color,
356+
boxShadow:`0 1.2vh 2vh ${data.color}`,
357+
})
358+
359+
$(".textui").fadeIn("fast")
360+
} else {
361+
$(".textui").fadeOut("fast")
362+
}
296363
}

import.lua

+18-3
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,31 @@ setmetatable(MSK.Progress, {
4949
end
5050
})
5151

52+
-- MSK.Timeout(ms, cb, data)
53+
setmetatable(MSK.Timeout, {
54+
__call = function(self, ...)
55+
return self.Set(...)
56+
end
57+
})
58+
59+
-- MSK.TextUI(key, text, color)
60+
setmetatable(MSK.TextUI, {
61+
__call = function(self, ...)
62+
self.Show(...)
63+
end
64+
})
65+
5266
if context == 'client' then
67+
-- MSK.Request(request, hasLoaded, assetType, asset, timeout, ...)
5368
setmetatable(MSK.Request, {
54-
__call = function(_, request, hasLoaded, assetType, asset, timeout, ...)
55-
return MSK.Request.Streaming(request, hasLoaded, assetType, asset, timeout, ...)
69+
__call = function(self, ...)
70+
return self.Streaming(...)
5671
end
5772
})
5873
end
5974

6075
if context == 'server' then
61-
-- MSK.Check(repo)
76+
-- MSK.Check({auhtor = 'MSK-Scripts', name = 'msk_core', download? = 'url'})
6277
setmetatable(MSK.Check, {
6378
__call = function(self, ...)
6479
self.Version(...)

0 commit comments

Comments
 (0)