Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ Config.LockpickItems = {

---Play sounds using game audio (sound natives) instead of through NUI.
Config.NativeAudio = true

-- Are you using mythic inventory
Config.MythicInventory = false
85 changes: 85 additions & 0 deletions server/framework/mythic-base.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
local cachedJobs = {}

-- Triggered when the mythic job resource is finished loaded
AddEventHandler("Jobs:Server:Startup", function()
-- Store the jobs into the cached table, so they can be referenced later, without recalling
cachedJobs = Jobs:GetAll()
end)

local function retrieveComponents()
Fetch = exports["mythic-base"]:FetchComponent("Fetch")
Jobs = exports["mythic-base"]:FetchComponent("Jobs")
Inventory = exports["mythic-base"]:FetchComponent("Inventory")
end

AddEventHandler("ox_doorlock:Shared:DependencyUpdate", retrieveComponents)

AddEventHandler("Core:Shared:Ready", function()
exports["mythic-base"]:RequestDependencies("ox_doorlock", {
"Fetch",
"Jobs",
"Inventory"
}, function(error)
if #error > 0 then
Logger:Critical("ox_doorlock", "Failed To Load All Dependencies")
return
end

retrieveComponents()
end)
end)

function GetPlayer(playerId)
local player = { source = playerId }
return player
end

function GetCharacterId(player)
local char = Fetch:Source(player.source):GetData("Character")
if not char then return -1 end

return char:GetData("SID")
end

function IsPlayerInGroup(player, filter)
if not player then return false end

local char = Fetch:Source(player.source):GetData("Character")
if not char then return false end

if type(filter) == "string" then
return Jobs.Permissions:HasJob(player.source, filter)
end

for job, grade in pairs(filter) do
if cachedJobs[job] then
local jobData = Jobs.Permissions:HasJob(player.source, job)
if jobData and jobData.Grade.Level >= grade then
return true
end
end
end

return false
end

if Config.MythicInventory then
function DoesPlayerHaveItem(player, items, removeItem)
if not player then return false end

local char = Fetch:Source(player.source):GetData("Character")
if not char then return false end

for i = 1, #items do
local item = items[i]
local itemName = item.name or item
if Inventory.Items:Has(char:GetData("SID"), 1, itemName, 1) then
if removeItem or item.remove then
Inventory.Items:Remove(char:GetData("SID"), 1, itemName, 1)
end

return itemName
end
end
end
end
26 changes: 14 additions & 12 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,22 @@ end
---@param items string[] | { name: string, remove?: boolean, metadata?: string }[]
---@param removeItem? boolean
---@return string?
function DoesPlayerHaveItem(player, items, removeItem)
local playerId = player.source or player.PlayerData.source

for i = 1, #items do
local item = items[i]
local itemName = item.name or item
local data = ox_inventory:Search(playerId, 'slots', itemName, item.metadata)[1]
if not Config.MythicInventory then
function DoesPlayerHaveItem(player, items, removeItem)
local playerId = player.source or player.PlayerData.source

for i = 1, #items do
local item = items[i]
local itemName = item.name or item
local data = ox_inventory:Search(playerId, 'slots', itemName, item.metadata)[1]

if data and data.count > 0 then
if removeItem or item.remove then
ox_inventory:RemoveItem(playerId, itemName, 1, nil, data.slot)
end

if data and data.count > 0 then
if removeItem or item.remove then
ox_inventory:RemoveItem(playerId, itemName, 1, nil, data.slot)
return itemName
end

return itemName
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion server/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function utils.getFilesInDirectory(path, pattern)
return files, fileCount
end

local frameworks = { 'es_extended', 'ND_Core', 'ox_core', 'qbx_core' }
local frameworks = { 'es_extended', 'ND_Core', 'ox_core', 'qbx_core', 'mythic-base' }
local sucess = false

for i = 1, #frameworks do
Expand Down
1 change: 1 addition & 0 deletions types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
---@field LockpickItems string[]
---@field NativeAudio boolean
---@field DrawSprite { [0]: DrawSpriteProps, [1]: DrawSpriteProps }
---@field MythicInventory boolean