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. Client

ESX

CreateThread(function()
    if Config.framework ~= 'ESX' then return end
    ESX = exports['es_extended']:getSharedObject()

    local PlayerData = ESX.GetPlayerData()

-- ReUpdatePlayerData

    function UpdatePlayerData()
        PlayerData = ESX.GetPlayerData()
    end
	
-- 	GetPlayerJobName

    function GetPlayerJobName()
        UpdatePlayerData()
        if PlayerData and PlayerData.job and PlayerData.job.name then
            return PlayerData.job.name
        end
        return nil
    end

-- 	GetPlayerJobGrade

    function GetPlayerJobGrade()
        UpdatePlayerData()
        if PlayerData and PlayerData.job and PlayerData.job.grade then
            return PlayerData.job.grade
        end
        return nil
    end

-- GetPlayerData

    function GetPlayerData(callback)
        UpdatePlayerData()
        if callback ~= nil then
            callback(PlayerData)
        end
    end

    local callback = nil

-- GetPlayer character.lastname, character.firstname

    function GetPlayerCharInfo(cb)
        callback = cb
        UpdatePlayerData()
        local identifier = PlayerData.identifier

        TriggerServerEvent('peace-speedcamera:GetPlayerCharInfo', identifier)
    end


    RegisterNetEvent('peace-speedcamera:ReceivePlayerCharInfo')
    AddEventHandler('peace-speedcamera:ReceivePlayerCharInfo', function(character)
        if callback then
            callback(character.firstname, character.lastname)
        end
    end)

-- Notification
	
    function sendNotification(message, title, theme)
        if Config.notificationType == "bulletin" then
            exports.bulletin:SendAdvanced({
                message = message,
                title = Config.notification.title,
                theme = theme,
                subject = Config.notification.subject,
                icon = Config.notification.icon,
                timeout = Config.notification.timeout,
                position = Config.notification.Position,
                progress = Config.notification.Progress,
                queue = Config.notification.Queue,
                stacking = Config.notification.Stacking,
                showStackedCount = Config.notification.ShowStackedCount,
                animationOut = Config.notification.AnimationOut,
                animationTime = Config.notification.AnimationTime,
                flashCount = Config.notification.FlashCount,
                soundFile = Config.notification.SoundFile,
                soundVolume = Config.notification.SoundVolume,
            })
        elseif Config.notificationType == "ESX" then
            ESX.ShowNotification(message)
        elseif Config.notificationType == "BasicNotification" then
            TriggerEvent('RadarNotification', message)
        else
            -- Type de notification non reconnu, effectuez une action par défaut
            print(Lang.NotifyNotFound)
        end
    end

    RegisterNetEvent('peace-speedcamera:GetSpeedCameraData')
    AddEventHandler('peace-speedcamera:GetSpeedCameraData', function(SpeedKM, finalBillingPrice, cameraID, cameraName, speedlimit, group, distance, playerCoords)
        GetPlayerCharInfo(function(firstname, lastname)
            local speedover = SpeedKM - speedlimit
            local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false)
            local plate = GetVehicleNumberPlateText(vehicle)
            local coords = GetEntityCoords(vehicle)
            local streetName, crossing = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
            local address = GetStreetNameFromHashKey(streetName)
            local vehicleModel = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
            local vehicleType = GetVehicleClassFromName(vehicleModel)
        
            TriggerServerEvent('peace-speedcamera:SaveSpeedCameraData', vehicleModel, vehicleType, address, plate, firstname, lastname, SpeedKM, speedover, finalBillingPrice, cameraID, cameraName, speedlimit, group)

-- ADD CUSTOM EVENT DISPATCH HERE 

        end)
    end)
end)

PreviousQBCoreNextQBOX

Last updated 1 year ago

📸
📂
💻