Fixed searching for vehicles, closes #398

Co-Authored-By: mortdudley <mortdudley@users.noreply.github.com>
This commit is contained in:
ElPumpo
2020-02-12 10:48:21 +01:00
parent 259cbc5b08
commit f83e05c83b
12 changed files with 25 additions and 60 deletions
+20 -10
View File
@@ -543,17 +543,28 @@ function LookupVehicle()
title = _U('search_database_title'),
}, function(data, menu)
local length = string.len(data.value)
if data.value == nil or length < 2 or length > 13 then
if not data.value or length < 2 or length > 8 then
ESX.ShowNotification(_U('search_database_error_invalid'))
else
ESX.TriggerServerCallback('esx_policejob:getVehicleFromPlate', function(owner, found)
if found then
ESX.ShowNotification(_U('search_database_found', owner))
ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo)
local elements = {{label = _U('plate', retrivedInfo.plate)}}
menu.close()
if not retrivedInfo.owner then
table.insert(elements, {label = _U('owner_unknown')})
else
ESX.ShowNotification(_U('search_database_error_not_found'))
table.insert(elements, {label = _U('owner', retrivedInfo.owner)})
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_infos', {
title = _U('vehicle_info'),
align = 'top-left',
elements = elements
}, nil, function(data2, menu2)
menu2.close()
end)
end, data.value)
menu.close()
end
end, function(data, menu)
menu.close()
@@ -620,7 +631,7 @@ function OpenVehicleInfosMenu(vehicleData)
ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo)
local elements = {{label = _U('plate', retrivedInfo.plate)}}
if retrivedInfo.owner == nil then
if not retrivedInfo.owner then
table.insert(elements, {label = _U('owner_unknown')})
else
table.insert(elements, {label = _U('owner', retrivedInfo.owner)})
@@ -699,7 +710,6 @@ end
function OpenBuyWeaponsMenu()
local elements = {}
local playerPed = PlayerPedId()
PlayerData = ESX.GetPlayerData()
for k,v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job.grade_name]) do
local weaponNum, weapon = ESX.GetWeapon(v.weapon)
@@ -836,7 +846,7 @@ function OpenGetStocksMenu()
}, function(data2, menu2)
local count = tonumber(data2.value)
if count == nil then
if not count then
ESX.ShowNotification(_U('quantity_invalid'))
else
menu2.close()
@@ -883,7 +893,7 @@ function OpenPutStocksMenu()
}, function(data2, menu2)
local count = tonumber(data2.value)
if count == nil then
if not count then
ESX.ShowNotification(_U('quantity_invalid'))
else
menu2.close()
-2
View File
@@ -93,8 +93,6 @@ Locales['br'] = {
['search_database'] = 'informação do veículo',
['search_database_title'] = 'informações do veículo - pesquisa com número de registro',
['search_database_error_invalid'] = 'que ~r~não~s~ é um número de registro ~y~válido~s~',
['search_database_error_not_found'] = 'esse número de ~y~registror~s~ ~r~não~s~ está registrado em um veículo!',
['search_database_found'] = 'o veículo está ~y~registrado~s~ para ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'Interagir com as rodovias',
['cone'] = 'Cones',
-2
View File
@@ -93,8 +93,6 @@ Locales['cs'] = {
['search_database'] = 'informace o vozidle',
['search_database_title'] = 'informace o vozidle - pomocí registracnich cisel',
['search_database_error_invalid'] = 'tohle ~r~neni~s~ ~y~spravne~s~ registracni cislo',
['search_database_error_not_found'] = 'toto ~y~registracni cislo~s~ je ~r~nespravne~s~ pro toto vozidlo!',
['search_database_found'] = 'vozidlo bylo ~y~registrovano~s~ k ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'interakce provozu',
['cone'] = 'kuzel',
-2
View File
@@ -93,8 +93,6 @@ Locales['de'] = {
['search_database'] = 'vehicle information',
['search_database_title'] = 'vehicle information - search with registration number',
['search_database_error_invalid'] = 'that is ~r~not~s~ a ~y~valid~s~ registration number',
['search_database_error_not_found'] = 'that ~y~registration number~s~ is ~r~not~s~ registered to an vehicle!',
['search_database_found'] = 'the vehicle is ~y~registered~s~ to ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'Straßeninteraktionen',
['cone'] = 'Hütchen',
-2
View File
@@ -93,8 +93,6 @@ Locales['en'] = {
['search_database'] = 'vehicle information',
['search_database_title'] = 'vehicle information - search with registration number',
['search_database_error_invalid'] = 'that is ~r~not~s~ a ~y~valid~s~ registration number',
['search_database_error_not_found'] = 'that ~y~registration number~s~ is ~r~not~s~ registered to an vehicle!',
['search_database_found'] = 'the vehicle is ~y~registered~s~ to ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'interaction Traffic',
['cone'] = 'cone',
-2
View File
@@ -93,8 +93,6 @@ Locales['es'] = {
['search_database'] = 'vehicle information',
['search_database_title'] = 'vehicle information - search with registration number',
['search_database_error_invalid'] = 'that is ~r~not~s~ a ~y~valid~s~ registration number',
['search_database_error_not_found'] = 'that ~y~registration number~s~ is ~r~not~s~ registered to an vehicle!',
['search_database_found'] = 'the vehicle is ~y~registered~s~ to ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'Rutas de interacción',
['cone'] = 'Cono',
-2
View File
@@ -93,8 +93,6 @@ Locales['fi'] = {
['search_database'] = 'ajoneuvon tiedot',
['search_database_title'] = 'ajoneuvon tiedot - etsi rekisterinumerolla',
['search_database_error_invalid'] = 'tämä ~r~ei ole~s~ ~y~voimassa oleva~s~ rekisterinumero',
['search_database_error_not_found'] = 'tämä ~y~rekisterinumero~s~ ~r~ei~s~ ole rekistöröity ajoneuvoon!',
['search_database_found'] = 'ajoneuvo on ~y~rekistöröity~s~ henkilölle ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'liikenteen vuorovaikutus',
['cone'] = 'kartio',
-2
View File
@@ -93,8 +93,6 @@ Locales['fr'] = {
['search_database'] = 'vehicle information',
['search_database_title'] = 'informations sur le véhicule - recherche avec numéro d\'enregistrement',
['search_database_error_invalid'] = 'Ce n\'est ~r~pas~s~ un ~y~numéro d\'enregistrement valide~s~',
['search_database_error_not_found'] = 'ce ~y~numéro d\'enregistrement ~s~est~r~ pas ~s~ enregistré sur un véhicule!',
['search_database_found'] = 'le véhicule est ~y~enregistré~s~ à ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'interaction routière',
['cone'] = 'plot',
-2
View File
@@ -93,8 +93,6 @@ Locales['ko'] = {
['search_database'] = '차량 정보',
['search_database_title'] = '차량 정보 - 등록번호로 검색',
['search_database_error_invalid'] = '~y~유효한~s~ 등록 번호가 ~r~아닙니다.~s~',
['search_database_error_not_found'] = '그 ~y~등록 번호~s~는 차량에 등록되지 ~r~않았습니다!~s~',
['search_database_found'] = '이 차량은 ~b~%s~s~에 ~y~등록되었습니다~s~',
-- Traffic interaction
['traffic_interaction'] = '교통 상호 작용',
['cone'] = '원뿔',
-2
View File
@@ -93,8 +93,6 @@ Locales['pl'] = {
['search_database'] = 'informacje o pojeździe',
['search_database_title'] = 'informacjeo pojeździe - przeszukaj używając numeru rejestracyjnego',
['search_database_error_invalid'] = 'to ~r~nie~s~ jest ~y~poprawny~s~ rnumer rejestracyjny',
['search_database_error_not_found'] = 'ten ~y~numer rejestracyjny~s~ ~r~nie jest~s~ zarejestrowany do tego pojazdu!',
['search_database_found'] = 'pojazd jest ~y~zarejestrowany~s~ do ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'interakcje dla ruchu drogowego',
['cone'] = 'pachołek',
-2
View File
@@ -93,8 +93,6 @@ Locales['sv'] = {
['search_database'] = 'fordonsuppgifter',
['search_database_title'] = 'fordonsuppgifter - sök med registreringsnummer',
['search_database_error_invalid'] = 'det är ~r~inte~s~ ett ~y~giltigt~s~ registreringsnummer',
['search_database_error_not_found'] = 'det ~y~registreringsnummeret~s~ är ~r~inte~s~ registrerat till något fordon!',
['search_database_found'] = 'detta fordon är ~y~registrerat~s~ till ~b~%s~s~',
-- Traffic interaction
['traffic_interaction'] = 'trafiksåtgärder',
['cone'] = 'kon',
+5 -30
View File
@@ -207,22 +207,19 @@ ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb,
if xPlayer then
retrivedInfo.owner = xPlayer.getName()
cb(retrivedInfo)
else
MySQL.Async.fetchAll('SELECT name, firstname, lastname FROM users WHERE identifier = @identifier', {
elseif Config.EnableESXIdentity then
MySQL.Async.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', {
['@identifier'] = result[1].owner
}, function(result2)
if result2[1] then
if Config.EnableESXIdentity then
retrivedInfo.owner = ('%s %s'):format(result2[1].firstname, result2[1].lastname)
else
retrivedInfo.owner = result2[1].name
end
retrivedInfo.owner = ('%s %s'):format(result2[1].firstname, result2[1].lastname)
cb(retrivedInfo)
else
cb(retrivedInfo)
end
end)
else
cb(retrivedInfo)
end
else
cb(retrivedInfo)
@@ -230,28 +227,6 @@ ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb,
end)
end)
ESX.RegisterServerCallback('esx_policejob:getVehicleFromPlate', function(source, cb, plate)
MySQL.Async.fetchAll('SELECT owner FROM owned_vehicles WHERE plate = @plate', {
['@plate'] = plate
}, function(result)
if result[1] then
MySQL.Async.fetchAll('SELECT name, firstname, lastname FROM users WHERE identifier = @identifier', {
['@identifier'] = result[1].owner
}, function(result2)
if Config.EnableESXIdentity then
cb(('%s %s'):format(result2[1].firstname, result2[1].lastname), true)
else
cb(result2[1].name, true)
end
end)
else
cb(_U('unknown'), false)
end
end)
end)
ESX.RegisterServerCallback('esx_policejob:getArmoryWeapons', function(source, cb)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
local weapons = store.get('weapons')