Skip to content

Commit

Permalink
feat(management/qbox): qbx-management support for BossManagedOutfits (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TheiLLeniumStudios authored Apr 24, 2023
1 parent 3fd721d commit db5090d
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 39 deletions.
41 changes: 3 additions & 38 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ local client = client
local currentZone = nil
local radialOptionAdded = false

local ManagementItemIDs = {
Gang = nil,
Boss = nil
}

local reloadSkinTimer = GetGameTimer()

local TargetPeds = {
Expand Down Expand Up @@ -119,36 +114,6 @@ local function LoadPlayerUniform()
end)
end

local function RemoveManagementMenuItems()
if ManagementItemIDs.Boss then
exports["qb-management"]:RemoveBossMenuItem(ManagementItemIDs.Boss)
end
if ManagementItemIDs.Gang then
exports["qb-management"]:RemoveGangMenuItem(ManagementItemIDs.Gang)
end
end

local function AddManagementMenuItems()
local eventName = "illenium-appearance:client:OutfitManagementMenu"
local menuItem = {
header = _L("outfitManagement.title"),
icon = "fa-solid fa-shirt",
params = {
event = eventName,
args = {
backEvent = eventName
}
}
}
menuItem.txt = _L("outfitManagement.jobText")
menuItem.params.args.type = "Job"
ManagementItemIDs.Boss = exports["qb-management"]:AddBossMenuItem(menuItem)

menuItem.txt = _L("outfitManagement.gangText")
menuItem.params.args.type = "Gang"
ManagementItemIDs.Gang = exports["qb-management"]:AddGangMenuItem(menuItem)
end

local function RemoveRadialMenuOption()
if radialOptionAdded then
if Config.UseOxRadial then
Expand All @@ -174,7 +139,7 @@ function InitAppearance()
end)
ResetBlips()
if Config.BossManagedOutfits then
AddManagementMenuItems()
Management.AddItems()
end
RestorePlayerStats()
end
Expand All @@ -199,8 +164,8 @@ AddEventHandler("onResourceStop", function(resource)
RemoveRadialMenuOption()
end
end
if Config.BossManagedOutfits and GetResourceState("qb-management") == "started" then
RemoveManagementMenuItems()
if Config.BossManagedOutfits then
Management.RemoveItems()
end
end
end)
Expand Down
35 changes: 35 additions & 0 deletions client/management/management.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Management = {}

Management.ItemIDs = {
Gang = nil,
Boss = nil
}

function Management.IsQB()
local resName = "qb-management"
if GetResourceState(resName) ~= "missing" then
Management.ResourceName = resName
return true
end
return false
end

function Management.IsQBX()
local resName = "qbx-management"
if GetResourceState(resName) ~= "missing" then
Management.ResourceName = resName
return true
end
return false
end

function Management.RemoveItems()
if GetResourceState(Management.ResourceName) ~= "started" then return end

if Management.ItemIDs.Boss then
exports[Management.ResourceName]:RemoveBossMenuItem(Management.ItemIDs.Boss)
end
if Management.ItemIDs.Gang then
exports[Management.ResourceName]:RemoveGangMenuItem(Management.ItemIDs.Gang)
end
end
18 changes: 18 additions & 0 deletions client/management/qb.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if not Management.IsQB() then return end

function Management.AddItems()
local menuItem = {
header = _L("outfitManagement.title"),
icon = "fa-solid fa-shirt",
params = {
event = "illenium-appearance:client:OutfitManagementMenu"
}
}
menuItem.txt = _L("outfitManagement.jobText")
menuItem.params.args.type = "Job"
Management.ItemIDs.Boss = exports[Management.ResourceName]:AddBossMenuItem(menuItem)

menuItem.txt = _L("outfitManagement.gangText")
menuItem.params.args.type = "Gang"
Management.ItemIDs.Gang = exports[Management.ResourceName]:AddGangMenuItem(menuItem)
end
17 changes: 17 additions & 0 deletions client/management/qbx.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if not Management.IsQBX() then return end

function Management.AddItems()
local menuItem = {
title = _L("outfitManagement.title"),
icon = "fa-solid fa-shirt",
event = "illenium-appearance:client:OutfitManagementMenu",
args = {}
}
menuItem.description = _L("outfitManagement.jobText")
menuItem.args.type = "Job"
Management.ItemIDs.Boss = exports[Management.ResourceName]:AddBossMenuItem(menuItem)

menuItem.description = _L("outfitManagement.gangText")
menuItem.args.type = "Gang"
Management.ItemIDs.Gang = exports[Management.ResourceName]:AddGangMenuItem(menuItem)
end
3 changes: 3 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ client_scripts {
"client/target/target.lua",
"client/target/qb.lua",
"client/target/ox.lua",
"client/management/management.lua",
"client/management/qb.lua",
"client/management/qbx.lua",
"client/stats.lua",
"client/defaults.lua",
"client/blips.lua",
Expand Down
2 changes: 1 addition & 1 deletion server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ RegisterNetEvent("illenium-appearance:server:saveManagementOutfit", function(out

lib.notify(src, {
title = _L("outfits.save.success.title"),
description = string.format(_L("outfits.save.success.description"), outfitData.name),
description = string.format(_L("outfits.save.success.description"), outfitData.Name),
type = "success",
position = Config.NotifyOptions.position
})
Expand Down

0 comments on commit db5090d

Please sign in to comment.