cl_utils.lua
local jobEvent = "QBCore:Client:OnJobUpdate" --
local loadEvent = "QBCore:Client:OnPlayerLoaded"
CreateThread(function()
if GetResourceState("qbx_core") == "started" then
jobEvent = "QBCore:Client:OnJobUpdate"
loadEvent = "QBCore:Client:OnPlayerLoaded"
elseif GetResourceState("es_extended") == "started" then
jobEvent = "esx:setJob"
loadEvent = 'esx:playerLoaded'
elseif GetResourceState("qb-core") == "started" then
jobEvent = "QBCore:Client:OnJobUpdate"
loadEvent = "QBCore:Client:OnPlayerLoaded"
end
end)
RegisterNetEvent(loadEvent, function()
print("saas")
PlayerLoaded()
end)
RegisterNetEvent(jobEvent, function()
UpdatePlayerData()
end)
RegisterCommand('test2', function()
exports.ox_inventory:openInventory('stash', "police-ak4y-stash")
end)
CreateThread(function()
if Config.Interaction == "target" then
for k,v in pairs(Config.BossMenus) do
exports["ak4y-core"]:AddZoneToTargeting(
v.coord,
90.0,
vec3(0.45, 0.35, 0.45),
"Open Boss Menu",
"ak4y-bossmenu:openMenu",
nil,
nil,
2.5,
"fas fa-sign-in-alt"
)
end
elseif Config.Interaction == "drawtext" then
local sleep = 1000
CreateThread(function()
while true do
Wait(sleep)
local inzone = false
for k,v in pairs(Config.BossMenus) do
if GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), v.coord, false) < 15 then
inzone = k
sleep = 1
end
end
if inzone then
if GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), Config.BossMenus[inzone].coord, false) < 2 then
Draw3DText({
text = "[E] Open Boss Menu",
coords = Config.BossMenus[inzone].coord,
})
if IsControlJustReleased(0, 38) then
if exports["ak4y-core"]:GetPlayerJob() == Config.BossMenus[inzone].job then
TriggerEvent("ak4y-bossmenu:openMenu")
else
exports["ak4y-core"]:NotifyViaFramework("You are not a member of this job!", "error")
end
end
else
sleep = 1000
end
end
end
end)
end
end)
function Draw3DText(data)
local text = data.text
local x = data.coords.x
local y = data.coords.y
local z = data.coords.z
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(true)
AddTextComponentString(text)
SetDrawOrigin(x,y,z, 0)
DrawText(0.0, 0.0)
local factor = (string.len(text)) / 370
DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
ClearDrawOrigin()
end
RegisterNUICallback('GetInventoryItems', function(data, cb)
local inv = false
for k,v in pairs(Config.BossMenus) do
if GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), v.coord, false) < 15 then
inv = k .. "-ak4y-stash"
end
end
if inv then
local newdata = CORE:Trigger('ak4y-bossmenu:GetInventoryItems', inv)
for k,v in pairs(newdata["items"]) do
v.myphoto = Config.ItemImagePatch .. v.name .. ".png"
end
cb(newdata)
else
cb(false)
end
end)
RegisterNetEvent('ak4y-bossmenu:CallAction-cl', function()
exports["ak4y-core"]:NotifyViaFramework("BOSS IS CALLING")
--you can add your dispatch or etc.
end)
Last updated