Lunar Heist Contracts

https://lunar-scripts.tebex.io/package/6346140

Import & overrides

In lunar_heistcontracts root directory create a file called imports.lua, in which copy-paste the following code:

imports.lua
local isServer = IsDuplicityVersion()
local appId = 'lunar_heistcontracts'

if not isServer then
  local OriginalRegisterNUICallback = RegisterNUICallback
  local overrides = {}
  local profile = {}

  function SetNuiFocus(hasCursor, disableInput) end

  function SendNUIMessage(data)
      if (data and data.action == 'updateProfile') then
          profile = data.data or {}
      end

      exports.fd_laptop:sendAppMessage(appId, data)
  end

  function RegisterNUICallback(name, callback)
      if name ~= 'hideFrame' then
          return OriginalRegisterNUICallback(name, callback)
      end

      overrides[name] = callback
      return OriginalRegisterNUICallback(name, callback)
  end

  function closeTablet()
      if (not overrides.hideFrame) then
          return
      end

      overrides.hideFrame({}, function() end)
  end

  RegisterNetEvent('lunar_contracts:closeTablet', closeTablet)

  local function openTablet()
      exports.fd_laptop:sendAppMessage(appId, {
          action = 'updateProfile',
          data = profile
      })
  end
  RegisterNetEvent('lunar_contracts:openTablet', openTablet)
end

if isServer then
  CreateThread(function()
      while GetResourceState("fd_laptop") ~= "started" do
          Wait(500)
      end

      local added, errorMessage = exports.fd_laptop:addCustomApp({
          id = appId,
          name = "Heists",
          isDefaultApp = true,
          needsUpdate = false,
          icon = 'boosting.svg',
          ui = ("https://cfx-nui-%s/web/build/index.html"):format(GetCurrentResourceName()),
          overrides = {
              ("https://cfx-nui-%s/web/dist/lunarOverrides.js"):format('fd_laptop'),
          },
          groups = { 'police' },
          keepAlive = false,
          ignoreInternalLoading = true,
          windowActions = {
              isResizable = false,
              isMaximizable = false,
              isClosable = true,
              isMinimizable = true,
              isDraggable = false
          },
          windowDefaultStates = {
              isMaximized = true,
              isMinimized = false
          },
          onUseServer = function(source)
              TriggerClientEvent('lunar_contracts:openTablet', source)
          end,
          onCloseServer = function(source)
              TriggerClientEvent('lunar_contracts:closeTablet', source)
          end
      })

      if not added then
          print("Could not add app:", errorMessage)
      end
  end)
end

Edit fxmanifest.lua

At the root of lunar_heistcontracts directory open fxmanifest.lua file with your preferred file editor and add imports.lua to shared_scripts block. After edit, shared_scripts block should look like this:

fxmanifest.lua
  shared_scripts {
      'imports.lua', -- Add this line
      '@ox_lib/init.lua',
      'init.lua',
      'config/config.lua',
      'config/contracts/*.lua'
  }

also, comment out UI line in fxmanifest.lua:

fxmanifest.lua
  ui_page 'web/build/index.html' -- Comment this line

should look like this:

fxmanifest.lua
  -- ui_page 'web/build/index.html' -- Comment this line

Edit fxmanifest.lua

At the root of lunar_heistcontracts directory open fxmanifest.lua file with your preferred file editor and add imports.lua to shared_scripts block. After edit, shared_scripts block should look like this:

fxmanifest.lua
  shared_scripts {
      'imports.lua', -- Add this line
      '@ox_lib/init.lua',
      'init.lua',
      'config/config.lua',
      'config/contracts/*.lua'
  }

Restart / Start server

Once you completed steps above, restart or start your server and enjoy KUB Trucking while using our laptop.