This commit is contained in:
Nordi98 2025-07-14 18:34:49 +02:00
parent 19fb68f805
commit 01d047b3cc
53 changed files with 3222 additions and 5 deletions

View file

@ -0,0 +1,65 @@
local resourceName = 'es_extended'
SetTimeout(0, function()
local ESX = exports[resourceName]:getSharedObject()
GetPlayer = ESX.GetPlayerFromId
if not ESX.GetConfig().OxInventory then
function RemoveItem(playerId, item)
local player = GetPlayer(playerId)
if player then player.removeInventoryItem(item, 1) end
end
---@param player table
---@param items string[] | { name: string, remove?: boolean, metadata?: string }[]
---@param removeItem? boolean
---@return string?
function DoesPlayerHaveItem(player, items, removeItem)
for i = 1, #items do
local item = items[i]
local itemName = item.name or item
local data = player.getInventoryItem(itemName)
if data?.count > 0 then
if removeItem or item.remove then
player.removeInventoryItem(itemName, 1)
end
return itemName
end
end
end
end
end)
function GetCharacterId(player)
return player.identifier
end
function IsPlayerInGroup(player, filter)
local type = type(filter)
if type == 'string' then
if player.job.name == filter then
return player.job.name, player.job.grade
end
else
local tabletype = table.type(filter)
if tabletype == 'hash' then
local grade = filter[player.job.name]
if grade and grade <= player.job.grade then
return player.job.name, player.job.grade
end
elseif tabletype == 'array' then
for i = 1, #filter do
if player.job.name == filter[i] then
return player.job.name, player.job.grade
end
end
end
end
end

View file

@ -0,0 +1,36 @@
local resourceName = 'ND_Core'
local NDCore = exports[resourceName]
function GetPlayer(src)
return NDCore:getPlayer(src)
end
function GetCharacterId(player)
return player.id
end
function IsPlayerInGroup(player, groups)
local type = type(groups)
if type == "string" then
return player.getGroup(groups)
end
if table.type(groups) == "array" then
for i = 1, #groups do
local groupName = groups[i]
local groupInfo = player.getGroup(groupName)
if groupInfo then
return groupName, groupInfo.rank
end
end
return
end
for groupName, grade in pairs(groups) do
local groupInfo = player.getGroup(groupName)
if groupInfo and grade and grade <= groupInfo.rank then
return groupName, groupInfo.rank
end
end
end

View file

@ -0,0 +1,16 @@
if not lib.checkDependency('ox_core', '0.21.3', true) then return end
local Ox = require '@ox_core.lib.init' --[[@as OxServer]]
GetPlayer = Ox.GetPlayer
---@param player OxPlayerServer
function GetCharacterId(player)
return player.charId
end
---@param player OxPlayerServer
---@param groups string | string[] | table<string, number>
function IsPlayerInGroup(player, groups)
return player.getGroup(groups)
end

View file

@ -0,0 +1,97 @@
local resourceName = 'qb-core'
SetTimeout(0, function()
local QB = exports[resourceName]:GetCoreObject()
GetPlayer = QB.Functions.GetPlayer
if GetResourceState('ox_inventory') == 'missing' then
function RemoveItem(playerId, item, slot)
local player = GetPlayer(playerId)
if player then player.Functions.RemoveItem(item, 1, slot) end
end
---@param player table
---@param items string[] | { name: string, remove?: boolean, metadata?: string }[]
---@param removeItem? boolean
---@return string?
function DoesPlayerHaveItem(player, items, removeItem)
for i = 1, #items do
local item = items[i]
local itemName = item.name or item
if item.metadata then
local playerItems = player.Functions.GetItemsByName(itemName)
for j = 1, #playerItems do
local data = playerItems[j]
if data.info.type == item.metadata then
if removeItem or item.remove then
player.Functions.RemoveItem(itemName, 1, data.slot)
end
return itemName
end
end
else
local data = player.Functions.GetItemByName(itemName)
if data then
if item.remove then
player.Functions.RemoveItem(itemName, 1, data.slot)
end
return itemName
end
end
end
end
end
end)
function GetCharacterId(player)
return player.PlayerData.citizenid
end
local groups = { 'job', 'gang' }
function IsPlayerInGroup(player, filter)
local type = type(filter)
if type == 'string' then
for i = 1, #groups do
local data = player.PlayerData[groups[i]]
if data.name == filter then
return data.name, data.grade.level
end
end
else
local tabletype = table.type(filter)
if tabletype == 'hash' then
for i = 1, #groups do
local data = player.PlayerData[groups[i]]
local grade = filter[data.name]
if grade and grade <= data.grade.level then
return data.name, data.grade.level
end
end
elseif tabletype == 'array' then
for i = 1, #filter do
local group = filter[i]
for j = 1, #groups do
local data = player.PlayerData[groups[j]]
if data.name == group then
return data.name, data.grade.level
end
end
end
end
end
end