forked from Simnation/Main
fixes
This commit is contained in:
parent
fb68aaa337
commit
35451d0d0f
71 changed files with 3 additions and 6158 deletions
|
@ -1,84 +0,0 @@
|
|||
---@diagnostic disable: undefined-field
|
||||
ESX = nil
|
||||
QBCore = nil
|
||||
|
||||
if (GetResourceState('es_extended') == 'started') then
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
elseif (GetResourceState('qb-core') == 'started') then
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
end
|
||||
|
||||
Functions = {}
|
||||
|
||||
Functions.HasItem = function(playerId, itemName)
|
||||
if ESX then
|
||||
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||
return xPlayer.getInventoryItem(itemName).count > 0
|
||||
elseif QBCore then
|
||||
local Player = QBCore.Functions.GetPlayer(playerId)
|
||||
return Player.Functions.GetItemByName(itemName).amount > 0
|
||||
end
|
||||
end
|
||||
|
||||
Functions.RemoveItem = function(playerId, itemName, amount)
|
||||
if ESX then
|
||||
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||
xPlayer.removeInventoryItem(itemName, amount)
|
||||
elseif QBCore then
|
||||
local Player = QBCore.Functions.GetPlayer(playerId)
|
||||
Player.Functions.RemoveItem(itemName, amount)
|
||||
end
|
||||
end
|
||||
|
||||
Functions.GetPolicePlayers = function()
|
||||
if not Config.allowedJobs then
|
||||
return { -1 }
|
||||
end
|
||||
|
||||
local jobs = {}
|
||||
for jobName, _ in pairs(Config.allowedJobs) do
|
||||
jobs[#jobs + 1] = jobName
|
||||
end
|
||||
|
||||
local playerIds = {}
|
||||
|
||||
if ESX then
|
||||
local result = ESX.GetExtendedPlayers('job', jobs)
|
||||
for key, xPlayers in pairs(result) do
|
||||
for i = 1, #xPlayers do
|
||||
playerIds[#playerIds + 1] = xPlayers[i].source
|
||||
end
|
||||
end
|
||||
elseif QBCore then
|
||||
for jobName, _ in pairs(Config.allowedJobs) do
|
||||
local players = QBCore.Functions.GetPlayersOnDuty(jobName)
|
||||
for i = 1, #players do
|
||||
playerIds[#playerIds + 1] = players[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return playerIds
|
||||
end
|
||||
|
||||
--[[
|
||||
-- If you are using an older version of ESX, and the blips are not showing up, you can use this function instead of the one above.
|
||||
Functions.GetPolicePlayers = function()
|
||||
local jobs = {}
|
||||
for jobName, _ in pairs(Config.allowedJobs) do
|
||||
jobs[#jobs + 1] = jobName
|
||||
end
|
||||
|
||||
local playerIds = {}
|
||||
|
||||
for i = 1, #jobs do
|
||||
local jobName = jobs[i]
|
||||
local result = ESX.GetExtendedPlayers('job', jobName)
|
||||
for key, xPlayer in pairs(result) do
|
||||
playerIds[#playerIds + 1] = xPlayer.source
|
||||
end
|
||||
end
|
||||
|
||||
return playerIds
|
||||
end
|
||||
]]
|
Loading…
Add table
Add a link
Reference in a new issue