MSK Scripts
TebexGithubDiscordMusiker15
  • MSK Scripts
    • Welcome
  • Common Issues
    • Keymaster
  • Miscellaneous
    • Change Notifications
  • Scripts
    • MSK Core
      • Installation
      • Functions
        • Client
          • Ace Permission
          • Commands
          • Coords
          • Player
          • Points
          • Request
          • Scaleform
          • UI
            • Input
            • Numpad
            • Progressbar
            • TextUI
          • Vehicle
        • Shared
          • String
          • Math
          • Table
          • Timeout
          • Vector
        • Server
          • Ace Permission
          • Ban System
          • Commands
          • Player
          • Scaleform
          • UI
            • Input
            • Numpad
            • Progressbar
            • TextUI
    • MSK Banking
      • Installation
        • Paycheck Transaction
      • Config
      • Exports
        • Client
        • Server
      • Events
        • Client
        • Server
      • Server Callbacks
    • MSK EngineToggle
      • Guides
      • Exports
        • Client
      • Event Handler
        • Client
        • Server
    • MSK Fuel
      • Config
      • Exports
        • Client
    • MSK Garage
      • Config
      • Exports
        • Client
    • MSK Handcuffs
      • Guides
        • General Edits for Jobs
        • Jaksam Job Creator
        • Multichar
        • ox_inventory
      • Config
      • Admin Commands
      • Exports
        • Client
        • Server
      • Events
        • Client
        • Server
      • Event Handlers
    • MSK Radio
      • Config
      • Exports
        • Client
        • Server
      • Events
        • Server
    • MSK Simcard
      • Installation
        • Config.Database
      • Config
    • MSK VehicleKeys
      • Guides
        • Installation
        • Integrations
      • Config
      • Admin Commands
      • Exports
        • Client
        • Server
    • MSK Whitelist
      • Config
      • Exports
        • Client
        • Server
    • MSK Weaponammo
Powered by GitBook
On this page
  • MSK.String.Random
  • MSK.String.StartsWith
  • MSK.String.Trim
  • MSK.String.Split
  1. Scripts
  2. MSK Core
  3. Functions
  4. Shared

String

MSK.String.Random

Generate a Random String

Parameters length - number - The Length of the string

Returns text - string - The Text of the given length

local text = MSK.String.Random(length)

-- Example
local text = MSK.String.Random(3) -- abc
local text = string.upper(MSK.String.Random(3)) -- ABC

-- As an Export:
local text = exports.msk_core:GetRandomString(length)

MSK.String.StartsWith

Checks if the given string start with the given string

Parameters text - string - Text that should be checked letter - string - Letter to search for

Returns startsWith - boolean - Whether the text starts with the given letter

local text = 'Hello'
local startsWith = MSK.String.StartsWith(text, 'H') -- Returns true
local startsWith = MSK.String.StartsWith(text, 'e') -- Returns false

-- As an Export:
local text = exports.msk_core:StartsWith(text, letter)

MSK.String.Trim

Removes SPACEs in a string

Parameters text - string - Text that should be trimmed hardtrim - boolean - All spaces will be trimmed - Optional

Returns trimmed - string - The trimmed text

local trimmed = MSK.String.Trim(text, hardtrim)

-- Example
local text = ' Hello World '

-- Removes leading and trailing spaces
MSK.String.Trim(text) -- Output: 'Hello World'

-- Removes ALL spaces
MSK.String.Trim(text, true) -- Output: 'HelloWorld'

-- As an Export:
local text = exports.msk_core:Trim(text, hardtrim)

MSK.String.Split

Splits a string into two different strings

Parameters text - string - Text that should be splitted delimiter - string - Delimiter where should the text be splitted

Returns result - table - Includes the splitted string

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

-- As an Export:
local result = exports.msk_core:Split(text, delimiter)

Last updated 7 months ago