diff --git a/cl_plate_reader.lua b/cl_plate_reader.lua index 54b4fa9..1627deb 100644 --- a/cl_plate_reader.lua +++ b/cl_plate_reader.lua @@ -104,7 +104,7 @@ function READER:GetCamLocked( cam ) end -- Locks the given reader -function READER:LockCam( cam ) +function READER:LockCam( cam, playAudio ) -- Check that plate readers can actually be locked if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then -- Toggle the lock state @@ -114,8 +114,12 @@ function READER:LockCam( cam ) SendNUIMessage( { _type = "lockPlate", cam = cam, state = self:GetCamLocked( cam ) } ) -- Play a beep - if ( self:GetCamLocked( cam ) ) then - SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "plateAudio" ) } ) + if ( self:GetCamLocked( cam ) ) then + if ( playAudio ) then + SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "plateAudio" ) } ) + end + + TriggerEvent( "wk:onPlateLocked", cam, self:GetPlate( cam ), self:GetIndex( cam ) ) end end end @@ -186,11 +190,16 @@ function READER:Main() -- Automatically lock the plate if the scanned plate matches the BOLO if ( plate == self:GetBoloPlate() ) then - self:LockCam( cam ) + self:LockCam( cam, false ) + + SendNUIMessage( { _type = "audio", name = "plate_hit", vol = RADAR:GetSettingValue( "plateAudio" ) } ) end -- Send the plate information to the NUI side to update the UI SendNUIMessage( { _type = "changePlate", cam = cam, plate = plate, index = index } ) + + -- Trigger the event so developers can hook into the scanner + TriggerEvent( "wk:onPlateScanned", cam, plate, index ) end end end diff --git a/cl_radar.lua b/cl_radar.lua index e4dcb41..be5c77d 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -1626,12 +1626,12 @@ function RunControlManager() -- Locks front plate reader if ( IsDisabledControlJustPressed( 1, CONFIG.plate_front_lock_key ) ) then - READER:LockCam( "front" ) + READER:LockCam( "front", true ) end -- Locks front plate reader if ( IsDisabledControlJustPressed( 1, CONFIG.plate_rear_lock_key ) ) then - READER:LockCam( "rear" ) + READER:LockCam( "rear", true ) end end diff --git a/nui/radar.js b/nui/radar.js index dcdf76e..7e3ae9d 100644 --- a/nui/radar.js +++ b/nui/radar.js @@ -27,7 +27,10 @@ const audioNames = front: "front.ogg", rear: "rear.ogg", closing: "closing.ogg", - away: "away.ogg" + away: "away.ogg", + + // Plate reader + plate_hit: "plate_hit.ogg" } // Defines which audio needs to play for which direction diff --git a/nui/sounds/plate_hit.ogg b/nui/sounds/plate_hit.ogg new file mode 100644 index 0000000..463a82a Binary files /dev/null and b/nui/sounds/plate_hit.ogg differ