PEACESCRIPT Documentation
StoreDiscord
  • 👋Introduction
  • 📸PEACE-Speedcamera
    • 📜Config File
    • 📂Unlocked File
      • 🖥️Server
        • QBCore
        • ESX
        • QBOX
        • Custom
      • 💻Client
        • QBCore
        • ESX
        • QBOX
        • Custom
  • 📄PEACE-JobMenu
    • 📜Config File
    • 📂Unlocked File
      • 💻Client
        • QBCore
        • ESX
        • Custom
  • 📊PEACE-DutyLog
    • 📜Config File
    • 📂Unlocked File
      • 💻Client
        • QBCore
        • ESX
        • QBOX
        • Custom
        • Target
      • 🖥️Server
        • QBCore
        • ESX
        • QBOX
        • Custom
  • 🖋️PEACE-PropsManager
    • ⬇️Installation
    • 📜Configuration
    • ❓FAQ
    • 📂Unlocked File
      • 🖥️Server
        • QBCore
        • ESX
        • Custom
      • 💻Client
        • QBCore
        • ESX
        • Custom
Powered by GitBook
On this page
  1. PEACE-Speedcamera
  2. Unlocked File
  3. Server

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)
PreviousQBCoreNextQBOX

Last updated 1 year ago

📸
📂
🖥️