Shared Functions - Clientside & Serverside
MSK.GetConfig
returns the Config from msk_core
Copy local mskConfig = MSK.GetConfig()
MSK.Logging
Debug and Error Logs. You can change them in config.lua
Copy 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
Copy MSK.GetRandomString(length)
-- Example
MSK.GetRandomString( 3 ) -- abc
string.upper (MSK.GetRandomString( 3 )) -- ABC
MSK.StartsWith
Checks if the given string start with the given string
Copy local text = 'Hello'
local startsWith = MSK.StartsWith(text, 'H' ) -- Returns true
local startsWith = MSK.StartsWith(text, 'e' ) -- Returns false
MSK.SetTimeout
Add and Delete a timeout
Copy timeout = MSK.SetTimeout(miliseconds, function ()
-- waits miliseconds time // asyncron
end )
MSK.ClearTimeout
Deletes the Timeout
Copy MSK.ClearTimeout(timeout)
MSK.TableContains
Check if a value contains in a table
Copy 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
Copy 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
Copy 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.
Copy 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
Copy 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.
Copy 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,
},
}
MSK.GetPedVehicleSeat
Get the the vehicle seat the player is in
Parameters
playerPed - number
- The Player Ped
vehicle - int
- A vehicle handle
Retuns
seat - number
- vehicle seat the player is in
Copy local seat = MSK.GetPedVehicleSeat(playerPed, vehicle)
-- clientside
local seat = MSK.GetPedVehicleSeat(PlayerPedId(), GetVehiclePedIsIn(PlayerPedId()))
-- serverside
local seat = MSK.GetPedVehicleSeat(GetPlayerPed(source), GetVehiclePedIsIn(GetPlayerPed(source)))