Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #39 pull request #40

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 54 additions & 14 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -507,31 +507,37 @@ 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)
p:resolve(fines)
end, category)

fineList[category] = Citizen.Await(p)
end
end

local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')}
Expand Down Expand Up @@ -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 or amount <= 0 then
ESX.ShowNotification(TranslateCap('invalid_amount'))
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},
Expand Down Expand Up @@ -642,6 +681,7 @@ function OpenUnpaidBillsMenu(player)
end

ESX.OpenContext("right", elements, nil, nil)

end, GetPlayerServerId(player))
end

Expand Down
2 changes: 2 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ 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 = false -- Set to false to use a custom input fields for fines

Config.Locale = GetConvar('esx:locale', 'en')

Config.OxInventory = ESX.GetConfig().OxInventory
Expand Down
3 changes: 3 additions & 0 deletions locales/cs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Vehicle interaction
['vehicle_info'] = 'informace o vozidle',
['pick_lock'] = 'vypáčit vozidlo',
Expand Down
3 changes: 3 additions & 0 deletions locales/de.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Vehicle interaction
['vehicle_info'] = 'Fahrzeug Info',
['pick_lock'] = 'Fahrzeug Aufbrechen',
Expand Down
3 changes: 3 additions & 0 deletions locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
['invalid_amount'] = 'Error: Amount was not a number or invalid',
-- Vehicle Info Menu
['plate'] = 'plate: %s',
['owner_unknown'] = 'owner: Unknown',
Expand Down
3 changes: 3 additions & 0 deletions locales/es.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Vehicle interaction
['vehicle_info'] = 'Información del vehículo',
['pick_lock'] = 'Forzar coche',
Expand Down
3 changes: 3 additions & 0 deletions locales/fi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Vehicle interaction
['vehicle_info'] = 'ajoneuvon tiedot',
['pick_lock'] = 'tiirikoi ovet',
Expand Down
3 changes: 3 additions & 0 deletions locales/fr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Intéraction véhicule
['vehicle_info'] = 'infos véhicule',
['pick_lock'] = 'crocheter véhicule',
Expand Down
3 changes: 3 additions & 0 deletions locales/hu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = 'Írja be a bírság összegét',
['fine_enter_text'] = 'Adja meg a bírság okát',
['invalid_amount'] = 'Hiba: Az összeg nem szám vagy érvénytelen',
-- Vehicle interaction
['vehicle_info'] = 'Jármü infó',
['pick_lock'] = 'Jármü feltörése',
Expand Down
3 changes: 3 additions & 0 deletions locales/it.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Interazione veicolo
['vehicle_info'] = 'informazioni sul veicolo',
['pick_lock'] = 'forza la serratura del veicolo',
Expand Down
3 changes: 3 additions & 0 deletions locales/nl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Voertuig Interactie
['vehicle_info'] = 'Voertuig Informatie',
['pick_lock'] = 'Breek voertuig open',
Expand Down
3 changes: 3 additions & 0 deletions locales/pl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Vehicle interaction
['vehicle_info'] = 'informacje o pojeździe',
['pick_lock'] = 'odblokuj pojazd',
Expand Down
3 changes: 3 additions & 0 deletions locales/sr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
['invalid_amount'] = 'Error: Amount was not a number or invalid', --not translated
-- Vehicle Info Menu
['plate'] = 'Tablice: %s',
['owner_unknown'] = 'Vlasnik: Nepoznat',
Expand Down
1 change: 1 addition & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ ESX.RegisterServerCallback('esx_policejob:getFineList', function(source, cb, cat
end
end)


ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb, plate)
local retrivedInfo = {
plate = plate
Expand Down