Skip to content

Commit 9e7cf7c

Browse files
committed
Update v1.7.3
* Added new Notification NUI
1 parent 78800aa commit 9e7cf7c

File tree

8 files changed

+197
-11
lines changed

8 files changed

+197
-11
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.2
1+
1.7.3

client.lua

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,21 @@ MSK.Trim = function(str, bool)
3131
return (str:gsub("%s+", ""))
3232
end
3333

34-
MSK.Notification = function(text)
35-
SetNotificationTextEntry('STRING')
36-
AddTextComponentString(text)
37-
DrawNotification(false, true)
34+
MSK.Notification = function(message, info, duration, playSound)
35+
if Config.Notification == 'native' then
36+
SetNotificationTextEntry('STRING')
37+
AddTextComponentString(message)
38+
DrawNotification(false, true)
39+
else
40+
SendNUIMessage({
41+
message = message,
42+
duration = duration or 5000,
43+
type = info or 'default',
44+
map = IsRadarEnabled()
45+
})
46+
end
47+
48+
if playSound then PlaySoundFrontend(-1, "ATM_WINDOW", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1) end
3849
end
3950

4051
MSK.HelpNotification = function(text)
@@ -189,8 +200,8 @@ AddEventHandler("msk_core:responseCallback", function(requestId, ...)
189200
end)
190201

191202
RegisterNetEvent("msk_core:notification")
192-
AddEventHandler("msk_core:notification", function(text)
193-
MSK.Notification(text)
203+
AddEventHandler("msk_core:notification", function(message, info, duration, playSound)
204+
MSK.Notification(message, info, duration, playSound)
194205
end)
195206

196207
RegisterNetEvent('msk_core:advancedNotification')

config.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ Config.showCoords = {
99
enable = true,
1010
command = 'coords',
1111
groups = {'superadmin', 'admin'}
12-
}
12+
}
13+
----------------------------------------------------------------
14+
-- Set to 'native' for FiveM Native Notification
15+
-- Set to 'nui' for NUI Notification
16+
Config.Notification = 'nui'

fxmanifest.lua

Lines changed: 9 additions & 1 deletion
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 '1.7.2'
7+
version '1.7.3'
88

99
lua54 'yes'
1010

@@ -28,6 +28,14 @@ files {
2828
'import.lua'
2929
}
3030

31+
ui_page 'html/index.html'
32+
33+
files {
34+
'html/index.html',
35+
'html/style.css',
36+
'html/script.js'
37+
}
38+
3139
dependencies {
3240
'oxmysql'
3341
}

html/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>MSK Notify</title>
6+
<link rel="stylesheet" href="style.css">
7+
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
8+
</head>
9+
<body>
10+
<div class="container mapOff">
11+
</div>
12+
</body>
13+
<script src="script.js" type="text/javascript"></script>
14+
</html>

html/script.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
window.addEventListener('message', (event) => {
2+
if (event.data.map == true) {
3+
$('.container').removeClass('mapOff').addClass('mapOn');
4+
} else {
5+
$('.container').removeClass('mapOn').addClass('mapOff');
6+
}
7+
8+
notification(event.data.message, event.data.duration, event.data.type);
9+
})
10+
11+
const colors = {
12+
"~r~": "red",
13+
"~b~": "#378cbf",
14+
"~g~": "green",
15+
"~y~": "yellow",
16+
"~p~": "purple",
17+
"~c~": "grey",
18+
"~m~": "#212121",
19+
"~u~": "black",
20+
"~o~": "orange"
21+
}
22+
23+
const replaceColors = (str, obj) => {
24+
let strToReplace = str;
25+
26+
for (let id in obj) {
27+
strToReplace = strToReplace.replace(new RegExp(id, "g"), obj[id]);
28+
}
29+
30+
return strToReplace
31+
}
32+
33+
notification = (message, duration, type) => {
34+
for (color in colors) {
35+
if (message.includes(color)) {
36+
let obj = {};
37+
38+
obj[color] = `<span style='color: ${colors[color]}'>`;
39+
obj['~s~'] = '</span>';
40+
41+
message = replaceColors(message, obj);
42+
}
43+
}
44+
45+
const notification = $(`
46+
<div class="notify" id="${type}">
47+
<p>${message}</p>
48+
</div>
49+
`).appendTo(`.container`);
50+
51+
setTimeout(() => {
52+
notification.fadeOut(700);
53+
}, duration);
54+
55+
return notification;
56+
}

html/style.css

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#default {
2+
background-color: rgba(0, 0, 0, 0.445);
3+
border: gray 0.1vw solid;
4+
}
5+
6+
#info {
7+
background: radial-gradient(40vh circle at 0 -60%,#02021b,#00000000);
8+
border: darkblue 0.1vw solid;
9+
}
10+
11+
#success {
12+
background: radial-gradient(40vh circle at 0 -60%,#041b02,#00000000);
13+
border: green 0.1vw solid;
14+
}
15+
16+
#error {
17+
background: radial-gradient(40vh circle at 0 -60%,#1b0202,#00000000);
18+
border: darkred 0.1vw solid;
19+
}
20+
21+
#warning {
22+
background: radial-gradient(40vh circle at 0 -60%,#1b1002,#00000000);
23+
border: darkorange 0.1vw solid;
24+
}
25+
26+
body {
27+
margin: 0;
28+
padding: 0;
29+
overflow: hidden;
30+
}
31+
32+
.container {
33+
display: block;
34+
position: absolute;
35+
left: 1.5vw;
36+
width: 15%;
37+
height: 50%;
38+
display: flex;
39+
flex-direction: column-reverse;
40+
}
41+
42+
.mapOff {
43+
bottom: 2vw;
44+
}
45+
46+
.mapOn {
47+
bottom: 12vw;
48+
}
49+
50+
.notify {
51+
position: relative;
52+
padding: .6vw;
53+
margin-top: 1vw;
54+
max-width: 100%;
55+
border-radius: .5vw;
56+
animation: fadeIn .5s ease 0s 1 normal forwards;
57+
box-shadow: 0 0 5px black;
58+
}
59+
60+
.notify p {
61+
margin: 0;
62+
padding: 0;
63+
font-family: 'Poppins', sans-serif;
64+
font-size: .7vw;
65+
font-weight: 500;
66+
color: white;
67+
padding-left: .2vw;
68+
text-align: left;
69+
}
70+
71+
@keyframes fadeIn {
72+
0% {
73+
opacity: 0;
74+
transform: translateX(-300px);
75+
}
76+
77+
100% {
78+
opacity: 1;
79+
transform: translateX(0);
80+
}
81+
}
82+
83+
@keyframes fadeOut {
84+
0% {
85+
opacity: 1;
86+
transform: translateX(0);
87+
}
88+
89+
100% {
90+
opacity: 0;
91+
transform: translateX(-300px);
92+
}
93+
}

server.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ MSK.RegisterCommand = function(name, group, cb, console, framework, suggestion)
125125
end
126126
end
127127

128-
MSK.Notification = function(src, text)
129-
TriggerClientEvent('msk_core:notification', src, text)
128+
MSK.Notification = function(src, message, info, duration, playSound)
129+
TriggerClientEvent('msk_core:notification', src, message, info, duration, playSound)
130130
end
131131

132132
MSK.AdvancedNotification = function(src, text, title, subtitle, icon, flash, icontype)

0 commit comments

Comments
 (0)