diff --git a/client/main.lua b/client/main.lua index 5ea172e..5e0eab8 100644 --- a/client/main.lua +++ b/client/main.lua @@ -507,23 +507,29 @@ function OpenBodySearchMenu(player) end function OpenFineMenu(player) - local elements = { - {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')}, - {icon = "fas fa-scroll", title = TranslateCap('traffic_offense'), value = 0}, - {icon = "fas fa-scroll", title = TranslateCap('minor_offense'), value = 1}, - {icon = "fas fa-scroll", title = TranslateCap('average_offense'), value = 2}, - {icon = "fas fa-scroll", title = TranslateCap('major_offense'), value = 3} - } - - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} - OpenFineCategoryMenu(player, data.current.value) - end) + if Config.EnableFinePresets then + local elements = { + {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')}, + {icon = "fas fa-scroll", title = TranslateCap('traffic_offense'), value = 0}, + {icon = "fas fa-scroll", title = TranslateCap('minor_offense'), value = 1}, + {icon = "fas fa-scroll", title = TranslateCap('average_offense'), value = 2}, + {icon = "fas fa-scroll", title = TranslateCap('major_offense'), value = 3} + } + + ESX.OpenContext("right", elements, function(menu,element) + local data = {current = element} + OpenFineCategoryMenu(player, data.current.value) + end) + else + ESX.CloseContext() + ESX.CloseContext() + OpenFineTextInput(player) + end end local fineList = {} function OpenFineCategoryMenu(player, category) -if not fineList[category] then + if not fineList[category] then local p = promise.new() ESX.TriggerServerCallback('esx_policejob:getFineList', function(fines) @@ -531,7 +537,7 @@ if not fineList[category] then end, category) fineList[category] = Citizen.Await(p) -end + end local elements = { {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')} @@ -561,6 +567,39 @@ end end) end +function OpenFineTextInput(player) + Citizen.CreateThread(function() + local amount = 0 + local reason = '' + AddTextEntry('FMMC_KEY_TIP1', TranslateCap('fine_enter_amount')) + Citizen.Wait(0) + DisplayOnscreenKeyboard(1, 'FMMC_KEY_TIP1', '', '', '', '', '', 30) + while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do + Citizen.Wait(0) + end + if UpdateOnscreenKeyboard() ~= 2 then + amount = tonumber(GetOnscreenKeyboardResult()) + if amount == nil then + ESX.ShowNotification(TranslateCap('not_a_number')) + return + end + end + AddTextEntry('FMMC_KEY_TIP1', TranslateCap('fine_enter_text')) + Citizen.Wait(0) + DisplayOnscreenKeyboard(1, 'FMMC_KEY_TIP1', '', '', '', '', '', 120) + while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do + Citizen.Wait(0) + end + if UpdateOnscreenKeyboard() ~= 2 then + reason = GetOnscreenKeyboardResult() + end + Citizen.Wait(500) + TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), 'society_police', reason, amount) + OpenPoliceActionsMenu() + end) +end + + function LookupVehicle(elementF) local elements = { {unselectable = true, icon = "fas fa-car", title = elementF.title}, @@ -634,14 +673,18 @@ function OpenUnpaidBillsMenu(player) ESX.TriggerServerCallback('esx_billing:getTargetBills', function(bills) for k,bill in ipairs(bills) do elements[#elements+1] = { - unselectable = true, + unselectable = not Config.EnableFineRemoval, icon = "fas fa-scroll", title = ('%s - %s'):format(bill.label, TranslateCap('armory_item', ESX.Math.GroupDigits(bill.amount))), billId = bill.id } end - ESX.OpenContext("right", elements, nil, nil) + ESX.OpenContext('right', elements, function(menu, bill) + TriggerServerEvent('esx_policejob:removeFine', bill.billId) + ESX.CloseContext() + OpenUnpaidBillsMenu(player) + end, nil) end, GetPlayerServerId(player)) end diff --git a/config.lua b/config.lua index 9f94765..364fe12 100644 --- a/config.lua +++ b/config.lua @@ -20,6 +20,9 @@ Config.EnableCustomPeds = false -- Enable custom peds in cloak room? S Config.EnableESXService = false -- Enable esx service? Config.MaxInService = -1 -- How many people can be in service at once? Set as -1 to have no limit +Config.EnableFinePresets = true -- Set to false to use a custom input fields for fines +Config.EnableFineRemoval = true -- Enable to let officers remove fines + Config.Locale = GetConvar('esx:locale', 'en') Config.OxInventory = ESX.GetConfig().OxInventory diff --git a/locales/cs.lua b/locales/cs.lua index 2cc53c8..ef5b04d 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -85,6 +85,9 @@ Locales['cs'] = { ['licence_you_revoked'] = 'zrusil jsi %s ktery patril %s', ['no_players_nearby'] = 'zadny hrac pobliz!', ['being_searched'] = 'prave jsi prohledavan policii', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Vehicle interaction ['vehicle_info'] = 'informace o vozidle', ['pick_lock'] = 'vypáčit vozidlo', diff --git a/locales/de.lua b/locales/de.lua index 51c5ea7..8249faa 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -85,6 +85,9 @@ Locales['de'] = { ['licence_you_revoked'] = 'Du entziehst eine ~b~%s~s~ welche zu ~y~%s~s~ gehörte.', ['no_players_nearby'] = 'Es sind keine Personen in der Nähe!', ['being_searched'] = 'Du wirst von der Polizei durchsucht!', + ['fine_enter_amount'] = 'Gebe den Betrag der Geldstrafe ein', + ['fine_enter_text'] = 'Gebe den Grund der Geldstrafe ein', + ['not_a_number'] = 'Fehler: Die Eingabe muss eine Zahl sein', -- Vehicle interaction ['vehicle_info'] = 'Fahrzeug Info', ['pick_lock'] = 'Fahrzeug Aufbrechen', diff --git a/locales/en.lua b/locales/en.lua index 00262c2..93a9271 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -136,6 +136,9 @@ Locales['en'] = { ['average_offense'] = 'average Offense', ['major_offense'] = 'major Offense', ['fine_total'] = 'fine: %s', + ['fine_enter_amount'] = 'Enter the amount of the fine', + ['fine_enter_text'] = 'Enter the reason for the fine', + ['not_a_number'] = 'Error: Value was not a number', -- Vehicle Info Menu ['plate'] = 'plate: %s', ['owner_unknown'] = 'owner: Unknown', diff --git a/locales/es.lua b/locales/es.lua index 80c562a..ad37ad2 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -85,6 +85,9 @@ Locales['es'] = { ['licence_you_revoked'] = 'you revoked a %s which belonged to %s', ['no_players_nearby'] = 'no hay jugadores cerca', ['being_searched'] = 'you are being searched by the Police', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Vehicle interaction ['vehicle_info'] = 'Información del vehículo', ['pick_lock'] = 'Forzar coche', diff --git a/locales/fi.lua b/locales/fi.lua index 553d1e1..00a1d68 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -85,6 +85,9 @@ Locales['fi'] = { ['licence_you_revoked'] = 'sinä kumosit %s mikä kuului henkilölle %s', ['no_players_nearby'] = 'ei pelaajia lähettyvillä', ['being_searched'] = 'you are being searched by the Police', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Vehicle interaction ['vehicle_info'] = 'ajoneuvon tiedot', ['pick_lock'] = 'tiirikoi ovet', diff --git a/locales/fr.lua b/locales/fr.lua index ad151d4..70720bd 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -85,6 +85,9 @@ Locales['fr'] = { ['licence_you_revoked'] = 'vous avez révoqué un %s qui appartenait à %s', ['no_players_nearby'] = 'aucun joueur à proximité', ['being_searched'] = 'vous êtes recherché(e) par la Police', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Intéraction véhicule ['vehicle_info'] = 'infos véhicule', ['pick_lock'] = 'crocheter véhicule', diff --git a/locales/hu.lua b/locales/hu.lua index 7153441..5de9498 100644 --- a/locales/hu.lua +++ b/locales/hu.lua @@ -85,6 +85,9 @@ Locales['hu'] = { ['licence_you_revoked'] = 'visszavonta %s %s engedélyét', ['no_players_nearby'] = 'nincs a közeledben játékos!', ['being_searched'] = 'Téged éppen megmotoztak!', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Vehicle interaction ['vehicle_info'] = 'Jármü infó', ['pick_lock'] = 'Jármü feltörése', diff --git a/locales/it.lua b/locales/it.lua index e7983fc..d924da2 100644 --- a/locales/it.lua +++ b/locales/it.lua @@ -85,6 +85,9 @@ Locales['it'] = { ['licence_you_revoked'] = 'hai revocato una %s che apparteneva a %s', ['no_players_nearby'] = 'non ci sono giocatori nelle vicinanze!', ['being_searched'] = 'stai venendo perquisito dalla Polizia', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Interazione veicolo ['vehicle_info'] = 'informazioni sul veicolo', ['pick_lock'] = 'forza la serratura del veicolo', diff --git a/locales/nl.lua b/locales/nl.lua index 71d063c..01606c5 100644 --- a/locales/nl.lua +++ b/locales/nl.lua @@ -85,6 +85,9 @@ Locales['nl'] = { ['licence_you_revoked'] = 'Je hebt een %s van %s ingevorderd.', ['no_players_nearby'] = 'Geen spelers in de buurt!', ['being_searched'] = 'Je wordt gefouilleerd door de Politie', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Voertuig Interactie ['vehicle_info'] = 'Voertuig Informatie', ['pick_lock'] = 'Breek voertuig open', diff --git a/locales/pl.lua b/locales/pl.lua index 8360302..f603185 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -85,6 +85,9 @@ Locales['pl'] = { ['licence_you_revoked'] = 'unieważniasz %s które należały do %s', ['no_players_nearby'] = 'brak graczy w pobliżu', ['being_searched'] = 'you are being searched by the Police', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Vehicle interaction ['vehicle_info'] = 'informacje o pojeździe', ['pick_lock'] = 'odblokuj pojazd', diff --git a/locales/sr.lua b/locales/sr.lua index 2e2d11b..c54e276 100644 --- a/locales/sr.lua +++ b/locales/sr.lua @@ -129,6 +129,9 @@ Locales['sr'] = { ['average_offense'] = 'Prosečan prekršaj', ['major_offense'] = 'Veliki prekršaj', ['fine_total'] = 'kazna: %s', + ['fine_enter_amount'] = 'Enter the amount of the fine', --not translated + ['fine_enter_text'] = 'Enter the reason for the fine', --not translated + ['not_a_number'] = 'Error: Value was not a number', --not translated -- Vehicle Info Menu ['plate'] = 'Tablice: %s', ['owner_unknown'] = 'Vlasnik: Nepoznat', diff --git a/server/main.lua b/server/main.lua index 117aac0..617aac1 100644 --- a/server/main.lua +++ b/server/main.lua @@ -211,6 +211,11 @@ ESX.RegisterServerCallback('esx_policejob:getFineList', function(source, cb, cat end end) +RegisterNetEvent('esx_policejob:removeFine') +AddEventHandler('esx_policejob:removeFine', function(id) + MySQL.update('DELETE FROM billing WHERE id = ?', {id}) +end) + ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb, plate) local retrivedInfo = { plate = plate