Skip to content

Commit

Permalink
refactor(client/ox): update ox_core version dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Mar 1, 2024
1 parent bba746c commit 7bfc9c0
Showing 1 changed file with 4 additions and 40 deletions.
44 changes: 4 additions & 40 deletions client/framework/ox.lua
@@ -1,46 +1,10 @@
local playerGroups = exports.ox_core.GetPlayerData()?.groups or {}

AddEventHandler('ox:playerLoaded', function(data)
playerGroups = data.groups
end)

RegisterNetEvent('ox:setGroup', function(name, grade)
if source == '' then return end
playerGroups[name] = grade
end)
if not lib.checkDependency('ox_core', '0.21.3', true) then return end

local Ox = require '@ox_core.lib.init' --[[@as OxClient]]
local utils = require 'client.utils'
local player = Ox.GetPlayer()

---@diagnostic disable-next-line: duplicate-set-field
function utils.hasPlayerGotGroup(filter)
local _type = type(filter)

if _type == 'string' then
local grade = playerGroups[filter]

if grade then
return true
end
elseif _type == 'table' then
local tabletype = table.type(filter)

if tabletype == 'hash' then
for name, grade in pairs(filter) do
local playerGrade = playerGroups[name]

if playerGrade and grade <= playerGrade then
return true
end
end
elseif tabletype == 'array' then
for i = 1, #filter do
local name = filter[i]
local grade = playerGroups[name]

if grade then
return true
end
end
end
end
return player.hasGroup(filter)
end

0 comments on commit 7bfc9c0

Please sign in to comment.