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.Timeout.Set
  • MSK.Timeout.Clear
  • MSK.Timeout.Await
  1. Scripts
  2. MSK Core
  3. Functions
  4. Shared

Timeout

MSK.Timeout.Set

Set a new asyncron timeout

Parameters miliseconds - number - Time to wait cb - function - Callback Function

timeout = MSK.Timeout.Set(miliseconds, function(data)
    print(data) -- Output: 'Hello World'
end, 'Hello World')

-- You can also use:
timeout = MSK.Timeout(miliseconds, function(data)
    print(data) -- Output: 'Hello World'
end, 'Hello World')

-- As an Export:
local timeout = exports.msk_core:SetTimeout(miliseconds, cb)

MSK.Timeout.Clear

Clears the given timeout

Parameters timeout - number - Timeout ID

MSK.Timeout.Clear(timeout)

-- As an Export:
exports.msk_core:ClearTimeout(timeout)

MSK.Timeout.Await

Calls a function repeatedly until it receives a non-nil value, or it times out. The function result is then returned.

Parameters miliseconds - number - Time to wait cb - function - Callback Function errorMessage - string - Message on error

Returns value - ? - The given value

local value = MSK.Timeout.Await(5000, function()
    if math.random(0, 1) == 1 then 
        return 'abc' 
    end
end, 'This is an Error Message')

print(value) -- Output: 'abc'

-- As an Export:
local value = exports.msk_core:AwaitTimeout(ms, cb, errorMessage)

Last updated 6 months ago

Thanks to for this amazing function!

ox_lib