lb-tablet app

Add a BoostNet app to lb-tablet that opens the boosting tablet.

This adds a BoostNet app to lb-tablet. Opening it closes lb-tablet and opens the boosting tablet. The app does not check for the gg_boosting_tablet item, and it is hidden from police jobs.

1. Create the file

Create a new Lua file in lb-tablet/client/apps/custom, for example boostnet.lua.

2. Paste the code

Lua
local APP_IDENTIFIER, APP_NAME = 'boosting', 'BoostNet'
local LEO_JOBS = { police=true, sheriff=true, bcso=true, lspd=true, sasp=true, statepolice=true, highway=true, ranger=true, park_ranger=true }
local appRegistered, lastVisible = false, nil

local function getJobName()
    if GetResourceState('qbx_core') == 'started' then
        local pd = exports['qbx_core']:GetPlayerData()
        return pd and pd.job and pd.job.name and string.lower(pd.job.name)
    elseif GetResourceState('qb-core') == 'started' then
        local pd = exports['qb-core']:GetCoreObject().Functions.GetPlayerData()
        return pd and pd.job and pd.job.name and string.lower(pd.job.name)
    elseif GetResourceState('es_extended') == 'started' then
        local job = exports['es_extended']:getSharedObject().PlayerData.job
        return job and job.name and string.lower(job.name)
    end
end

local function shouldShowApp()
    local j = getJobName()
    return not (j and LEO_JOBS[j])
end

local function addApp()
    if appRegistered then return end
    exports['lb-tablet']:AddCustomApp({
        identifier  = APP_IDENTIFIER,
        name        = APP_NAME,
        icon        = 'https://i.ibb.co/3YspJmNp/image.png',
        defaultApp  = true,
        onOpen      = function()
            exports['lb-tablet']:ToggleOpen(false)
            TriggerServerEvent('gg_boosting:server:open_tablet')
        end,
    })
    appRegistered = true
end

local function removeApp()
    if appRegistered then
        exports['lb-tablet']:RemoveCustomApp(APP_IDENTIFIER)
        appRegistered = false
    end
end

local function refreshApp(force)
    local show = shouldShowApp()
    if not force and show == lastVisible then return end
    lastVisible = show
    if show then addApp() else removeApp() end
end

CreateThread(function()
    while not (exports['lb-tablet'] and exports['lb-tablet'].AddCustomApp) do Wait(100) end
    refreshApp(true)
end)

RegisterNetEvent('QBCore:Client:OnJobUpdate', function() refreshApp(true) end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() refreshApp(true) end)
RegisterNetEvent('esx:setJob', function() refreshApp(true) end)
RegisterNetEvent('esx:playerLoaded', function() refreshApp(true) end)

To show the app to everyone, make shouldShowApp return true. To change which jobs cannot see it, edit LEO_JOBS.

3. Restart

Restart your server. Open lb-tablet in game and tap BoostNet.

Support

Questions before you buy?

Ask the team in our Discord before you pay a thing. Setup help, update notes, giveaways and discount codes, all in one place.

831 online now2,241 members