Skip to content

Commit 2fd5b59

Browse files
committed
Update v2.3.2
* Fixed MSK.Split * Added MSK.StartsWith
1 parent 2e2fc8d commit 2fd5b59

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

client/main.lua

+7-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ MSK.DrawGenericText = function(text, outline, font, size, color, position)
172172
if not font then font = 0 end
173173
if not size then size = 0.34 end
174174
if not color then color = {r = 255, g = 255, b = 255, a = 255} end
175-
if not position then position = {height = 0.90, width = 0.50} end
175+
if not position then position = {width = 0.50, height = 0.90} end
176176

177177
SetTextColour(color.r, color.g, color.b, color.a)
178178
SetTextFont(font)
@@ -218,7 +218,7 @@ end
218218
exports('GetVehicleInDirection', MSK.GetVehicleInDirection)
219219

220220
MSK.IsVehicleEmpty = function(vehicle)
221-
if not vehicle or (vehicle and not DoesEntityExist(vehicle)) then return end
221+
assert(vehicle and DoesEntityExist(vehicle), 'Parameter "vehicle" is nil or the Vehicle does not exist')
222222
local passengers = GetVehicleNumberOfPassengers(vehicle)
223223
local driverSeatFree = IsVehicleSeatFree(vehicle, -1)
224224

@@ -259,7 +259,7 @@ end
259259
exports('GetPedVehicleSeat', MSK.GetPedVehicleSeat)
260260

261261
MSK.GetPedMugshot = function(ped, transparent)
262-
if not DoesEntityExist(ped) then return end
262+
assert(ped and DoesEntityExist(ped), 'Parameter "ped" is nil or the PlayerPed does not exist')
263263
local mugshot = transparent and RegisterPedheadshotTransparent(ped) or RegisterPedheadshot(ped)
264264

265265
while not IsPedheadshotReady(mugshot) do
@@ -292,6 +292,8 @@ exports('ProgressStop', MSK.ProgressStop)
292292
RegisterNetEvent("msk_core:progressbarStop", MSK.ProgressStop)
293293

294294
MSK.LoadAnimDict = function(dict)
295+
assert(dict and DoesAnimDictExist(dict), 'Parameter "dict" is nil or the AnimDict does not exist')
296+
295297
if not HasAnimDictLoaded(dict) then
296298
RequestAnimDict(dict)
297299

@@ -303,6 +305,8 @@ end
303305
exports('LoadAnimDict', MSK.LoadAnimDict)
304306

305307
MSK.LoadModel = function(modelHash)
308+
assert(modelHash and IsModelValid(modelHash), 'Parameter "modelHash" is nil or the Model does not exist')
309+
306310
if not HasModelLoaded(modelHash) then
307311
RequestModel(modelHash)
308312

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

99
lua54 'yes'
1010

server/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ GithubUpdater = function()
341341
elseif CurrentVersion ~= version then
342342
print(resourceName .. '^1 ✗ Resource Outdated. Please Update!^0 - ^5Current Version: ^1' .. CurrentVersion .. '^0')
343343
print('^5Latest Version: ^2' .. version .. '^0 - ^6Download here:^9 https://github.com/MSK-Scripts/msk_core/releases/tag/v'.. version .. '^0')
344-
print('')
344+
345345
for i=1, #decoded do
346346
if decoded[i]['version'] == CurrentVersion then
347347
break

shared/shared.lua

+28-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ for i = 65, 90 do table.insert(Charset, string.char(i)) end
55
for i = 97, 122 do table.insert(Charset, string.char(i)) end
66

77
MSK.GetRandomString = function(length)
8+
assert(length, 'Parameter "length" is nil on function MSK.GetRandomString')
89
math.randomseed(GetGameTimer())
910

1011
return length > 0 and MSK.GetRandomString(length - 1) .. Charset[math.random(1, #Charset)] or ''
@@ -18,21 +19,34 @@ end
1819
exports('GetConfig', MSK.GetConfig)
1920
exports('getConfig', MSK.GetConfig) -- Support for old Versions
2021

22+
MSK.StartsWith = function(str, startStr)
23+
assert(str and type(str) == 'string', 'Parameter "str" has to be a string on function MSK.StartsWith')
24+
assert(startStr and type(startStr) == 'string', 'Parameter "startStr" has to be a string on function MSK.StartsWith')
25+
return str:sub(1, #startStr) == startStr
26+
end
27+
exports('StartsWith', MSK.StartsWith)
28+
2129
MSK.Round = function(num, decimal)
30+
assert(num and tonumber(num), 'Parameter "num" has to be a number on function MSK.Round')
31+
assert(not decimal or decimal and tonumber(decimal), 'Parameter "decimal" has to be a number on function MSK.Round')
2232
return tonumber(string.format("%." .. (decimal or 0) .. "f", num))
2333
end
2434
exports('Round', MSK.Round)
2535

2636
MSK.Trim = function(str, bool)
27-
if bool then return (str:gsub("^%s*(.-)%s*$", "%1")) end
28-
return (str:gsub("%s+", ""))
37+
assert(str and tostring(str), 'Parameter "str" has to be a string on function MSK.Trim')
38+
str = tostring(str)
39+
if bool then return str:gsub("^%s*(.-)%s*$", "%1") end
40+
return str:gsub("%s+", "")
2941
end
3042
exports('Trim', MSK.Trim)
3143

3244
MSK.Split = function(str, delimiter)
45+
assert(str and type(str) == 'string', 'Parameter "str" has to be a string on function MSK.Split')
46+
assert(delimiter and type(delimiter) == 'string', 'Parameter "delimiter" has to be a string on function MSK.Split')
3347
local result = {}
3448

35-
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
49+
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
3650
table.insert(result, match)
3751
end
3852

@@ -41,8 +55,8 @@ end
4155
exports('Split', MSK.Split)
4256

4357
MSK.TableContains = function(tbl, val)
44-
if not tbl then return end
45-
if not val then return end
58+
assert(tbl and type(tbl) == 'table', 'Parameter "tbl" has to be a table on function MSK.TableContains')
59+
assert(val, 'Parameter "val" is nil on function MSK.TableContains')
4660

4761
if type(val) == 'table' then
4862
for k, v in pairs(tbl) do
@@ -65,6 +79,8 @@ MSK.Table_Contains = MSK.TableContains -- Support for old Versions
6579
exports('TableContains', MSK.TableContains)
6680

6781
MSK.Comma = function(int, tag)
82+
assert(int and tonumber(int), 'Parameter "int" has to be a number on function MSK.Comma')
83+
assert(not tag or tag and type(tag) == 'string' and not tonumber(tag), 'Parameter "tag" has to be a string on function MSK.Comma')
6884
if not tag then tag = '.' end
6985
local newInt = int
7086

@@ -82,6 +98,7 @@ exports('Comma', MSK.Comma)
8298

8399
local Timeout = 0
84100
MSK.SetTimeout = function(ms, cb)
101+
assert(ms and tonumber(ms), 'Parameter "ms" has to be a number on function MSK.SetTimeout')
85102
local requestId = Timeout + 1
86103

87104
SetTimeout(ms, function()
@@ -100,7 +117,7 @@ MSK.AddTimeout = MSK.SetTimeout -- Support for old Versions
100117
exports('SetTimeout', MSK.SetTimeout)
101118

102119
MSK.ClearTimeout = function(requestId)
103-
if not requestId then return end
120+
assert(requestId, 'Parameter "requestId" is nil on function MSK.ClearTimeout')
104121
Timeouts[requestId] = true
105122
end
106123
MSK.DelTimeout = MSK.ClearTimeout -- Support for old Versions
@@ -134,15 +151,17 @@ MSK.Logging = function(code, ...)
134151
local args = {...}
135152
table.remove(args, 1)
136153

137-
print(script, Config.LoggingTypes[action], ...)
154+
print(('%s %s'):format(script, Config.LoggingTypes[action]), ...)
138155
else
139-
print(script, Config.LoggingTypes[code], ...)
156+
assert(code and type(code) == 'string', 'Parameter "code" has to be a string on function MSK.Logging')
157+
print(('%s %s'):format(script, Config.LoggingTypes[code]), ...)
140158
end
141159
end
142160
MSK.logging = MSK.Logging -- Support for old Versions
143161
exports('Logging', MSK.Logging)
144162

145163
logging = function(code, ...)
146164
if not Config.Debug then return end
147-
print(Config.LoggingTypes[code], ...)
165+
local script = "[^2"..GetCurrentResourceName().."^0]"
166+
print(('%s %s'):format(script, Config.LoggingTypes[code]), ...)
148167
end

0 commit comments

Comments
 (0)