lb-tablet App
Guide Created by Jhookcrook617
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)
Last updated