Skip to content

Commit 1080238

Browse files
committed
Update v2.6.8
1 parent c614156 commit 1080238

File tree

11 files changed

+134
-13
lines changed

11 files changed

+134
-13
lines changed

client/functions/request.lua

+11-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ MSK.Request.Streaming = function(request, hasLoaded, assetType, asset, timeout,
1212
end
1313
exports('RequestStreaming', MSK.Request.Streaming)
1414

15+
setmetatable(MSK.Request, {
16+
__call = function(_, request, hasLoaded, assetType, asset, timeout, ...)
17+
return MSK.Request.Streaming(request, hasLoaded, assetType, asset, timeout, ...)
18+
end
19+
})
20+
1521
MSK.Request.ScaleformMovie = function(scaleformName, timeout)
1622
assert(scaleformName and type(scaleformName) == 'string', ("Parameter 'scaleformName' has to be a 'string' (reveived %s)"):format(type(scaleformName)))
1723

@@ -29,7 +35,7 @@ MSK.Request.AnimDict = function(animDict)
2935

3036
if HasAnimDictLoaded(animDict) then return animDict end
3137

32-
return MSK.Request(RequestAnimDict, HasAnimDictLoaded, 'animDict', animDict)
38+
return MSK.Request.Streaming(RequestAnimDict, HasAnimDictLoaded, 'animDict', animDict)
3339
end
3440
MSK.LoadAnimDict = MSK.Request.AnimDict -- Support for old Versions
3541
exports('LoadAnimDict', MSK.Request.AnimDict) -- Support for old Versions
@@ -42,7 +48,7 @@ MSK.Request.Model = function(model)
4248

4349
if HasModelLoaded(model) then return model end
4450

45-
return MSK.Request(RequestModel, HasModelLoaded, 'model', model)
51+
return MSK.Request.Streaming(RequestModel, HasModelLoaded, 'model', model)
4652
end
4753
MSK.LoadModel = MSK.Request.Model -- Support for old Versions
4854
exports('LoadModel', MSK.Request.Model) -- Support for old Versions
@@ -52,7 +58,7 @@ MSK.Request.AnimSet = function(animSet)
5258
assert(animSet and type(animSet) == 'string', ("Parameter 'animSet' has to be a 'string' (reveived %s)"):format(type(animSet)))
5359
if HasAnimSetLoaded(animSet) then return animSet end
5460

55-
return MSK.Request(RequestAnimSet, HasAnimSetLoaded, 'animSet', animSet)
61+
return MSK.Request.Streaming(RequestAnimSet, HasAnimSetLoaded, 'animSet', animSet)
5662
end
5763
exports('RequestAnimSet', MSK.Request.AnimSet)
5864

@@ -61,7 +67,7 @@ MSK.Request.PtfxAsset = function(ptFxName)
6167

6268
if HasNamedPtfxAssetLoaded(ptFxName) then return ptFxName end
6369

64-
return MSK.Request(RequestNamedPtfxAsset, HasNamedPtfxAssetLoaded, 'ptFxName', ptFxName)
70+
return MSK.Request.Streaming(RequestNamedPtfxAsset, HasNamedPtfxAssetLoaded, 'ptFxName', ptFxName)
6571
end
6672
exports('RequestPtfxAsset', MSK.Request.PtfxAsset)
6773

@@ -70,7 +76,7 @@ MSK.Request.TextureDict = function(textureDict)
7076

7177
if HasStreamedTextureDictLoaded(textureDict) then return textureDict end
7278

73-
return MSK.Request(RequestStreamedTextureDict, HasStreamedTextureDictLoaded, 'textureDict', textureDict)
79+
return MSK.Request.Streaming(RequestStreamedTextureDict, HasStreamedTextureDictLoaded, 'textureDict', textureDict)
7480
end
7581
exports('RequestTextureDict', MSK.Request.TextureDict)
7682

client/functions/showCoords.lua

+14
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ end
2828
exports('HideCoords', MSK.Coords.Hide)
2929
RegisterNetEvent('msk_core:hideCoords', MSK.Coords.Hide)
3030

31+
MSK.Coords.Copy = function(coords)
32+
if not coords then coords = MSK.Player.coords end
33+
local x, y, z, h = table.unpack(coords)
34+
local newCoords = {x = MSK.Math.Round(x, 2), y = MSK.Math.Round(y, 2), z = MSK.Math.Round(z, 2)}
35+
newCoords.h = h and MSK.Math.Round(h, 2)
36+
37+
SendNUIMessage({
38+
action = "copyCoords",
39+
value = MSK.CoordsToString(newCoords),
40+
})
41+
end
42+
exports('CopyCoords', MSK.Coords.Copy)
43+
RegisterNetEvent('msk_core:copyCoords', MSK.Coords.Copy)
44+
3145
MSK.Register('msk_core:doesShowCoords', function(source)
3246
return showCoords
3347
end)

config.lua

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ Config.showCoords = {
1818
command = 'coords',
1919
groups = {'superadmin', 'admin'}
2020
}
21+
22+
Config.copyCoords = {
23+
enable = true,
24+
command = 'copyCoords',
25+
groups = {'superadmin', 'admin'}
26+
}
2127
----------------------------------------------------------------
2228
-- Set to 'msk' for MSK UI Notification
2329
-- Set to 'custom' for Config.customNotification()

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.7'
7+
version '2.6.8'
88

99
lua54 'yes'
1010

html/script.js

+14
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ $(document).ready(function() {
4848
openNumpad(data);
4949
} else if (data.action == 'closeNumpad') {
5050
closeNumpad();
51+
} else if (data.action == 'copyCoords') {
52+
copyCoords(data.value);
5153
}
5254
})
5355
})
@@ -70,6 +72,18 @@ function playSound(sound, volume) {
7072
audio.play();
7173
}
7274

75+
function copyCoords(value) {
76+
console.log(`Copying ${value} to your clipboard`);
77+
const el = document.createElement('textarea');
78+
79+
el.value = value;
80+
document.body.appendChild(el);
81+
el.select();
82+
83+
document.execCommand('copy');
84+
document.body.removeChild(el);
85+
}
86+
7387
/* ----------------
7488
MSK Notification
7589
---------------- */

import.lua

+8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ setmetatable(MSK.Progress, {
4949
end
5050
})
5151

52+
if context == 'client' then
53+
setmetatable(MSK.Request, {
54+
__call = function(_, request, hasLoaded, assetType, asset, timeout, ...)
55+
return MSK.Request.Streaming(request, hasLoaded, assetType, asset, timeout, ...)
56+
end
57+
})
58+
end
59+
5260
if context == 'server' then
5361
-- MSK.Check(repo)
5462
setmetatable(MSK.Check, {

server/functions/player.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ local onPlayer = function(key, value, oldValue)
3636
if key == 'ped' or key == 'playerPed' then
3737
Player[playerId][key] = GetPlayerPed(playerId)
3838
elseif key == 'Notify' then
39-
Player[playerId][key] = value(function(...)
39+
Player[playerId][key] = function(...)
4040
MSK.Notification(playerId, ...)
41-
end)
41+
end
4242
elseif key == 'vehicle' then
4343
Player[playerId][key] = NetworkGetEntityFromNetworkId(value)
4444
Player[playerId]['vehNetId'] = value

server/functions/showCoords.lua

+30-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ if Config.showCoords.enable then
1313
})
1414
end
1515

16+
if Config.copyCoords.enable then
17+
MSK.RegisterCommand(Config.copyCoords.command, function(source, args, raw)
18+
MSK.Coords.Copy(source, args.playerId)
19+
end, {
20+
allowConsole = false,
21+
restricted = Config.copyCoords.groups,
22+
help = 'Copy coords to clipboard',
23+
params = {
24+
{name = 'playerId', type = 'playerId', help = 'Target players server id', optional = true}
25+
}
26+
})
27+
end
28+
1629
MSK.Coords.Show = function(playerId)
1730
if not playerId or playerId == 0 then return end
1831
TriggerClientEvent('msk_core:showCoords', playerId)
@@ -31,4 +44,20 @@ MSK.Coords.Hide = function(playerId)
3144
if not playerId or playerId == 0 then return end
3245
TriggerClientEvent('msk_core:hideCoords', playerId)
3346
end
34-
exports('HideCoords', MSK.Coords.Hide)
47+
exports('HideCoords', MSK.Coords.Hide)
48+
49+
MSK.Coords.Copy = function(playerId, targetId)
50+
if not playerId or playerId == 0 then return end
51+
local coords
52+
53+
if targetId then
54+
coords = MSK.Player[targetId].coords
55+
else
56+
coords = MSK.Player[playerId].coords
57+
end
58+
59+
if coords then
60+
TriggerClientEvent('msk_core:copyCoords', playerId, coords)
61+
end
62+
end
63+
exports('CopyCoords', MSK.Coords.Copy)

server/functions/version.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ MSK.Check.Dependency = function(resource, minimumVersion, showMessage)
9696
if currentVersion ~= minimumVersion then
9797
local cV = MSK.String.Split(currentVersion, '.')
9898
local mV = MSK.String.Split(minimumVersion, '.')
99-
local errMsg = ("^1Resource %s requires a minimum version of '%s' of resource '%s'! ^5Current Version: ^1%s^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion)
99+
local errMsg = ("^1resource %s requires minimum version '%s' of resource '%s'! (current version: %s)^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion)
100100

101101
for i = 1, #cV do
102102
local current, minimum = tonumber(cV[i]), tonumber(mV[i])
103103

104104
if current ~= minimum then
105105
if not current or current < minimum then
106106
if showMessage then
107-
print(errMsg)
107+
MSK.Logging('error', errMsg)
108108
end
109109

110110
return false, errMsg

shared/functions.lua

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ exports('Config', MSK.GetConfig)
66

77
MSK.Logging = function(code, ...)
88
assert(code and type(code) == 'string', 'Parameter "code" has to be a string on function MSK.Logging')
9-
local script = ('[^2%s^0]'):format(GetInvokingResource() or 'msk_core')
10-
print(('%s %s'):format(script, Config.LoggingTypes[code] or Config.LoggingTypes['debug']), ..., '^0')
9+
print(('%s %s'):format(('[^2%s^0]'):format(GetInvokingResource() or 'msk_core'), Config.LoggingTypes[code] or Config.LoggingTypes['debug']), ..., '^0')
1110
end
1211
MSK.logging = MSK.Logging -- Support for old Versions
1312
exports('Logging', MSK.Logging)

shared/vector.lua

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
local getTableHeading = function(coords)
2+
return coords.h or coords.w or coords.heading or 0.0
3+
end
4+
5+
MSK.CoordsToString = function(coords)
6+
assert(coords, 'Parameter "coords" has to be a vector on function MSK.CoordsToString')
7+
local typ = type(coords)
8+
9+
if typ == 'table' then
10+
if coords.h or coords.w then
11+
return string.format("vector4(%s, %s, %s, %s)", coords.x, coords.y, coords.z, getTableHeading(coords))
12+
end
13+
14+
return string.format("vector3(%s, %s, %s)", coords.x, coords.y, coords.z)
15+
elseif typ == 'vector3' then
16+
return string.format("vector3(%s, %s, %s)", coords.x, coords.y, coords.z)
17+
elseif typ == 'vector4' then
18+
return string.format("vector4(%s, %s, %s, %s)", coords.x, coords.y, coords.z, coords.w)
19+
end
20+
21+
return coords
22+
end
23+
exports('CoordsToString', MSK.CoordsToString)
24+
25+
MSK.VectorToVector = function(vec)
26+
local typ = type(vec)
27+
28+
if typ == 'vec4' or typ == 'vector4' then
29+
return vector3(vec.x, vec.y, vec.z)
30+
end
31+
32+
return vec
33+
end
34+
exports('VectorToVector', MSK.VectorToVector)
35+
36+
MSK.TableToVector = function(coords, toType)
37+
assert(coords and type(coords) == 'table', 'Parameter "tbl" has to be a table on function MSK.TableToVector')
38+
39+
if toType == 'vector3' then
40+
return vector3(coords.x, coords.y, coords.z)
41+
elseif toType == 'vector4' then
42+
return vector4(coords.x, coords.y, coords.z, getTableHeading(coords))
43+
end
44+
end
45+
exports('TableToVector', MSK.TableToVector)

0 commit comments

Comments
 (0)