Shared

Functions - Clientside & Serverside

MSK.GetConfig

returns the Config from msk_core

local mskConfig = MSK.GetConfig()

MSK.Logging

Debug and Error Logs. You can change them in config.lua

MSK.Logging(code, ...)

-- Example
MSK.Logging('info', 'value1', 'value2', ...)
MSK.Logging('debug', 'value1', 'value2', ...)
MSK.Logging('error', 'value1', 'value2', ...)

MSK.GetRandomString

Generate a Random String

MSK.GetRandomString(length)

-- Example
MSK.GetRandomString(3) -- abc
string.upper(MSK.GetRandomString(3)) -- ABC

MSK.SetTimeout

Add and Delete a timeout

timeout = MSK.SetTimeout(miliseconds, function()
    -- waits miliseconds time // asyncron
end)

MSK.DelTimeout

Delete a Timeout

MSK.DelTimeout(timeout)

MSK.TableContains

Check if a value contains in a table

table = {'value_1', 'value_2'}

-- Check if one of the values contains in the table
local contains = MSK.TableContains(table, {'value_1', 'value_5'})

-- Check if the value contains in the table
local contains = MSK.TableContains(table, 'value_1')

if contains then
    -- true
else
    -- false
end

MSK.Round

Round a number

MSK.Round(number, decimal)

-- Example
local num = 25.8385
MSK.Round(num) -- Output: 26
MSK.Round(num, 1) -- Output: 25.8
MSK.Round(num, 2) -- Output: 25.84

MSK.Trim

Removes SPACEs in a string

MSK.Trim(string, bool --[[optional]])

-- Example
local str = ' Hello World '
MSK.Trim(str) -- Output: 'HelloWorld' --[[Removes ALL spaces]]
MSK.Trim(str, true) -- Output: 'Hello World' --[[Removes leading and trailing spaces]]

MSK.Comma

Let your Number look like 1.000 f.e. for UIs, etc.

MSK.Comma(number, tag) -- tag is optional

-- Example
MSK.Comma(1000) -- Output: 1.000
MSK.Comma(1000, ',') -- Output: 1,000

MSK.Split

Splits a string into two different strings

local string = 'license:12345678'
print(MSK.Split(string, ':')[1], MSK.Split(string, ':')[2]) -- Output: license, 12345678

local string2 = '25M'
print(MSK.Split(string2, 'M')[1]) -- Output: 25

MSK.DumpTable

Dumps the given table to a readable string with a tree structure.

local dumpTable = {
  ['test'] = {name = 'test', action = '123'},
  test2 = {name = 'test2', action = 456},
}
print(MSK.DumpTable(dumpTable))

-- Output:
{
  ["test"] = {
    ["action"] = '123',
    ["name"] = test,
  },
  ["test2"] = {
    ["action"] = 456,
    ["name"] = test2,
  },
}

Last updated