Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(client/ox): update ox_core version dependency
- Loading branch information
Showing
1 changed file
with
4 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |