ESX
CreateThread(function()
if Config.framework ~= 'ESX' then return end
ESX = exports['es_extended']:getSharedObject()
-- GetPlayer
function GetPlayer()
local players = ESX.GetPlayers()
return players
end
-- Retrieves player's service status
function IsPlayerOnDuty(player)
local xPlayer = ESX.GetPlayerFromId(player)
if xPlayer then
local job = xPlayer.getJob()
if job and job.onduty then
return true
end
end
return false
end
-- Recover the player's profession
function GetPlayerJob(player)
local xPlayer = ESX.GetPlayerFromId(player)
if xPlayer then
local job = xPlayer.getJob()
return job
end
return nil
end
-- Retrieves the player's profession name
function GetPlayerJobName(player)
local xPlayer = ESX.GetPlayerFromId(player)
if xPlayer then
local job = xPlayer.getJob()
if job and job.name then
return job.name
end
end
return nil
end
function GetPlayerId(player)
return player
end
-- Server side event to retrieve player information -- firstname and lastname
RegisterServerEvent('peace-speedcamera:GetPlayerCharInfo')
AddEventHandler('peace-speedcamera:GetPlayerCharInfo', function(identifier)
local source = source
MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier', {
['@identifier'] = identifier
}, function(result)
if result and #result > 0 then
local firstname = result[1].firstname
local lastname = result[1].lastname
TriggerClientEvent('peace-speedcamera:ReceivePlayerCharInfo', source, { firstname = firstname, lastname = lastname })
else
TriggerClientEvent('peace-speedcamera:ReceivePlayerCharInfo', source, nil)
end
end)
end)
-- Fines
function ProcessFinalBillingPriceValue(finalBillingPrice, group)
local player = ESX.GetPlayerFromId(source)
if player then
player.removeAccountMoney('bank', finalBillingPrice)
local agentJob = group
local addMoneyTo = Config.FinesTransf[agentJob]
if addMoneyTo then
TriggerEvent('esx_addonaccount:getSharedAccount', addMoneyTo, function(account)
account.addMoney(finalBillingPrice)
end)
-- print("Argent ajouté à " .. addMoneyTo .. " pour prise de radar " .. agentJob)
else
print("No money mapping is defined for agent work: " .. agentJob)
end
else
print("Error: Player not found.")
end
end
end)
Last updated