46 lines
1.2 KiB
Lua
46 lines
1.2 KiB
Lua
if Config.esxSettings.enabled then
|
|
ESX = nil
|
|
|
|
if Config.esxSettings.useNewESXExport then
|
|
ESX = exports['es_extended']:getSharedObject()
|
|
else
|
|
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
|
end
|
|
|
|
function HasItem(player, item)
|
|
local xPlayer = ESX.GetPlayerFromId(player)
|
|
|
|
return xPlayer.getInventoryItem(item).count >= 1
|
|
end
|
|
|
|
function IsPolice(player)
|
|
local xPlayer = ESX.GetPlayerFromId(player)
|
|
if not xPlayer then
|
|
return false
|
|
end
|
|
local job = xPlayer.getJob()
|
|
|
|
return Contains(Config.policeJobNames, job.name)
|
|
end
|
|
|
|
function GetPoliceCount()
|
|
local currentOfficers = 0
|
|
for _, playerId in ipairs(GetPlayers()) do
|
|
playerId = tonumber(playerId)
|
|
if IsPolice(playerId) then
|
|
currentOfficers = currentOfficers + 1
|
|
end
|
|
end
|
|
return currentOfficers
|
|
end
|
|
|
|
function AddMoney(player, amount)
|
|
local xPlayer = ESX.GetPlayerFromId(player)
|
|
if not xPlayer then
|
|
return false
|
|
end
|
|
|
|
xPlayer.addAccountMoney(Config.esxSettings.moneyAccount, amount)
|
|
end
|
|
end
|