From 5926584595a935014c6f4e4637e72e85a9dc78bc Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 25 Jul 2018 12:11:04 +0200 Subject: [PATCH] Closes #130, updated to support new vehicle db system --- client/main.lua | 58 ++++++++++---------- config.lua | 12 ++++- locales/br.lua | 3 +- locales/de.lua | 3 +- locales/en.lua | 3 +- locales/es.lua | 3 +- locales/fi.lua | 1 + locales/fr.lua | 1 + locales/pl.lua | 1 + locales/sv.lua | 1 + server/main.lua | 140 ++++++++++++------------------------------------ 11 files changed, 83 insertions(+), 143 deletions(-) diff --git a/client/main.lua b/client/main.lua index 9e7ebbce..5d7652db 100644 --- a/client/main.lua +++ b/client/main.lua @@ -466,7 +466,7 @@ function OpenPoliceActionsMenu() elements = { {label = _U('citizen_interaction'), value = 'citizen_interaction'}, {label = _U('vehicle_interaction'), value = 'vehicle_interaction'}, - {label = _U('object_spawner'), value = 'object_spawner'}, + {label = _U('object_spawner'), value = 'object_spawner'} } }, function(data, menu) @@ -500,6 +500,7 @@ function OpenPoliceActionsMenu() if action == 'identity_card' then OpenIdentityCardMenu(closestPlayer) elseif action == 'body_search' then + TriggerServerEvent('esx_policejob:message', GetPlayerServerId(closestPlayer), _U('being_searched')) OpenBodySearchMenu(closestPlayer) elseif action == 'handcuff' then TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer)) @@ -524,7 +525,7 @@ function OpenPoliceActionsMenu() menu2.close() end) elseif data.current.value == 'vehicle_interaction' then - local elements = {} + local elements = {} local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) local vehicle = ESX.Game.GetVehicleInDirection() @@ -535,7 +536,7 @@ function OpenPoliceActionsMenu() table.insert(elements, {label = _U('impound'), value = 'impound'}) end - --table.insert(elements, {label = _U('search_database'), value = 'search_database'}) + table.insert(elements, {label = _U('search_database'), value = 'search_database'}) ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'vehicle_interaction', @@ -544,9 +545,9 @@ function OpenPoliceActionsMenu() align = 'top-left', elements = elements }, function(data2, menu2) - coords = GetEntityCoords(playerPed) - vehicle = ESX.Game.GetVehicleInDirection() - action = data2.current.value + coords = GetEntityCoords(playerPed) + vehicle = ESX.Game.GetVehicleInDirection() + action = data2.current.value if action == 'search_database' then LookupVehicle() @@ -899,7 +900,7 @@ function LookupVehicle() title = _U('search_database_title'), }, function(data, menu) local length = string.len(data.value) - if data.value == nil or length < 8 or length > 13 then + if data.value == nil or length < 2 or length > 13 then ESX.ShowNotification(_U('search_database_error_invalid')) else ESX.TriggerServerCallback('esx_policejob:getVehicleFromPlate', function(owner, found) @@ -983,32 +984,28 @@ end function OpenVehicleInfosMenu(vehicleData) - ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(infos) + ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo) - local elements = {} + local elements = {} - table.insert(elements, {label = _U('plate', infos.plate), value = nil}) + table.insert(elements, {label = _U('plate', retrivedInfo.plate), value = nil}) - if infos.owner == nil then - table.insert(elements, {label = _U('owner_unknown'), value = nil}) - else - table.insert(elements, {label = _U('owner', infos.owner), value = nil}) - end + if retrivedInfo.owner == nil then + table.insert(elements, {label = _U('owner_unknown'), value = nil}) + else + table.insert(elements, {label = _U('owner', retrivedInfo.owner), value = nil}) + end - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'vehicle_infos', - { - title = _U('vehicle_info'), - align = 'top-left', - elements = elements, - }, - nil, - function(data, menu) - menu.close() - end - ) + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_infos', + { + title = _U('vehicle_info'), + align = 'top-left', + elements = elements + }, nil, function(data, menu) + menu.close() + end) - end, vehicleData.plate) + end, vehicleData.plate) end @@ -1029,7 +1026,7 @@ function OpenGetWeaponMenu() { title = _U('get_weapon_menu'), align = 'top-left', - elements = elements, + elements = elements }, function(data, menu) @@ -1060,7 +1057,6 @@ function OpenPutWeaponMenu() local weaponHash = GetHashKey(weaponList[i].name) if HasPedGotWeapon(playerPed, weaponHash, false) and weaponList[i].name ~= 'WEAPON_UNARMED' then - --local ammo = GetAmmoInPedWeapon(playerPed, weaponHash) table.insert(elements, {label = weaponList[i].label, value = weaponList[i].name}) end @@ -1071,7 +1067,7 @@ function OpenPutWeaponMenu() { title = _U('put_weapon_menu'), align = 'top-left', - elements = elements, + elements = elements }, function(data, menu) diff --git a/config.lua b/config.lua index f0c4f361..c78100c3 100644 --- a/config.lua +++ b/config.lua @@ -31,7 +31,7 @@ Config.PoliceStations = { Scale = 1.2, Colour = 29, }, - -- https://wiki.fivem.net/wiki/Weapons + -- https://wiki.rage.mp/index.php?title=Weapons AuthorizedWeapons = { { name = 'WEAPON_NIGHTSTICK', price = 200 }, { name = 'WEAPON_COMBATPISTOL', price = 300 }, @@ -83,7 +83,7 @@ Config.PoliceStations = { } --- https://wiki.fivem.net/wiki/Vehicles +-- https://wiki.rage.mp/index.php?title=Vehicles Config.AuthorizedVehicles = { Shared = { { @@ -118,6 +118,10 @@ Config.AuthorizedVehicles = { } }, + intendent = { + + }, + lieutenant = { { model = 'riot', @@ -129,6 +133,10 @@ Config.AuthorizedVehicles = { } }, + chef = { + + }, + boss = { } diff --git a/locales/br.lua b/locales/br.lua index 0523c396..fb3ea1a1 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -47,7 +47,8 @@ Locales['br'] = { ['license_revoke'] = 'revoke license', ['license_revoked'] = 'your ~b~%s~s~ has been ~y~revoked~s~!', ['licence_you_revoked'] = 'you revoked a ~b~%s~s~ which belonged to ~y~%s~s~', - ['no_players_nearby'] = 'Nenhum jogador nas proximidades', + ['no_players_nearby'] = 'nenhum jogador nas proximidades', + ['being_searched'] = 'you are being ~y~searched~s~ by the ~b~Police~s~', -- Vehicle interaction ['vehicle_info'] = 'Informações', ['pick_lock'] = 'Trancar veículo', diff --git a/locales/de.lua b/locales/de.lua index de79ebd8..310179f2 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -47,7 +47,8 @@ Locales['de'] = { ['license_revoke'] = 'revoke license', ['license_revoked'] = 'your ~b~%s~s~ has been ~y~revoked~s~!', ['licence_you_revoked'] = 'you revoked a ~b~%s~s~ which belonged to ~y~%s~s~', - ['no_players_nearby'] = 'Keine Spieler in der Nähe', + ['no_players_nearby'] = 'keine Spieler in der Nähe', + ['being_searched'] = 'you are being ~y~searched~s~ by the ~b~Police~s~', -- Vehicle interaction ['vehicle_info'] = 'Fahrzeug Info', ['pick_lock'] = 'Fahrzeug öffnen', diff --git a/locales/en.lua b/locales/en.lua index c376dd94..2c9003f9 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -47,7 +47,8 @@ Locales['en'] = { ['license_revoke'] = 'revoke license', ['license_revoked'] = 'your ~b~%s~s~ has been ~y~revoked~s~!', ['licence_you_revoked'] = 'you revoked a ~b~%s~s~ which belonged to ~y~%s~s~', - ['no_players_nearby'] = 'no players nearby', + ['no_players_nearby'] = 'there is no player(s) nearby!', + ['being_searched'] = 'you are being ~y~searched~s~ by the ~b~Police~s~', -- Vehicle interaction ['vehicle_info'] = 'vehicle Info', ['pick_lock'] = 'lockpick Vehicle', diff --git a/locales/es.lua b/locales/es.lua index d44c2295..5cbbfac9 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -47,7 +47,8 @@ Locales['es'] = { ['license_revoke'] = 'revoke license', ['license_revoked'] = 'your ~b~%s~s~ has been ~y~revoked~s~!', ['licence_you_revoked'] = 'you revoked a ~b~%s~s~ which belonged to ~y~%s~s~', - ['no_players_nearby'] = 'No hay jugadores cerca', + ['no_players_nearby'] = 'no hay jugadores cerca', + ['being_searched'] = 'you are being ~y~searched~s~ by the ~b~Police~s~', -- Vehicle interaction ['vehicle_info'] = 'Información del vehículo', ['pick_lock'] = 'Forzar coche', diff --git a/locales/fi.lua b/locales/fi.lua index 95fcce8f..b5b08d83 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -48,6 +48,7 @@ Locales['fi'] = { ['license_revoked'] = 'sinun ~b~%s~s~ ~y~kumottiin~s~!', ['licence_you_revoked'] = 'sinä kumosit ~b~%s~s~ mikä kuului henkilölle ~y~%s~s~', ['no_players_nearby'] = 'ei pelaajia lähettyvillä', + ['being_searched'] = 'you are being ~y~searched~s~ by the ~b~Police~s~', -- Vehicle interaction ['vehicle_info'] = 'ajoneuvon tiedot', ['pick_lock'] = 'tiirikoi ovet', diff --git a/locales/fr.lua b/locales/fr.lua index 9dbb382c..7ddf43d2 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -48,6 +48,7 @@ Locales['fr'] = { ['license_revoked'] = 'votre ~b~%s~s~ a été ~y~révoqué~s~!', ['licence_you_revoked'] = 'vous avez révoqué un ~b~%s~s~ qui appartenait à ~y~%s~s~', ['no_players_nearby'] = 'aucun joueur à proximité', + ['being_searched'] = 'you are being ~y~searched~s~ by the ~b~Police~s~', -- Vehicle interaction ['vehicle_info'] = 'infos véhicule', ['pick_lock'] = 'crocheter véhicule', diff --git a/locales/pl.lua b/locales/pl.lua index d7d2e2a6..0b98fc61 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -49,6 +49,7 @@ Locales['pl'] = { ['license_revoked'] = 'twoja licencja ~b~%s~s~ została ~y~unieważniona~s~!', ['licence_you_revoked'] = 'unieważniłeś ~b~%s~s~ które należały do ~y~%s~s~', ['no_players_nearby'] = 'brak graczy w pobliżu', + ['being_searched'] = 'you are being ~y~searched~s~ by the ~b~Police~s~', -- Vehicle interaction ['vehicle_info'] = 'informacje o pojeździe', ['pick_lock'] = 'odblokuj pojazd', diff --git a/locales/sv.lua b/locales/sv.lua index a5c8133c..0b13d8a3 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -48,6 +48,7 @@ Locales['sv'] = { ['license_revoked'] = 'Ditt ~b~%s~s~ har blivit ~y~återkallat~s~!', ['licence_you_revoked'] = 'du återkallade ett ~b~%s~s~ som tillhörde ~y~%s~s~', ['no_players_nearby'] = 'det finns ingen i närheten', + ['being_searched'] = 'du blir ~y~visiterad~s~ av ~b~Polisen~s~', -- Vehicle interaction ['vehicle_info'] = 'fordon', ['pick_lock'] = 'bryt upp fordon', diff --git a/server/main.lua b/server/main.lua index 59dfb92a..080333da 100644 --- a/server/main.lua +++ b/server/main.lua @@ -226,114 +226,32 @@ end) ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb, plate) - if Config.EnableESXIdentity then + MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE @plate = plate', { + ['@plate'] = plate + }, function(result) - MySQL.Async.fetchAll( - 'SELECT * FROM owned_vehicles', - {}, - function(result) + local retrivedInfo = { + plate = plate + } - local foundIdentifier = nil + if result[1] then - for i=1, #result, 1 do + MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier', { + ['@identifier'] = result[1].owner + }, function(result2) - local vehicleData = json.decode(result[i].vehicle) - - if vehicleData.plate == plate then - foundIdentifier = result[i].owner - break - end - - end - - if foundIdentifier ~= nil then - - MySQL.Async.fetchAll( - 'SELECT * FROM users WHERE identifier = @identifier', - { - ['@identifier'] = foundIdentifier - }, - function(result) - - local ownerName = result[1].firstname .. " " .. result[1].lastname - - local infos = { - plate = plate, - owner = ownerName - } - - cb(infos) - - end - ) - - else - - local infos = { - plate = plate - } - - cb(infos) - - end - - end - ) - - else - - MySQL.Async.fetchAll( - 'SELECT * FROM owned_vehicles', - {}, - function(result) - - local foundIdentifier = nil - - for i=1, #result, 1 do - - local vehicleData = json.decode(result[i].vehicle) - - if vehicleData.plate == plate then - foundIdentifier = result[i].owner - break - end - - end - - if foundIdentifier ~= nil then - - MySQL.Async.fetchAll( - 'SELECT * FROM users WHERE identifier = @identifier', - { - ['@identifier'] = foundIdentifier - }, - function(result) - - local infos = { - plate = plate, - owner = result[1].name - } - - cb(infos) - - end - ) - - else - - local infos = { - plate = plate - } - - cb(infos) - - end - - end - ) - - end + if Config.EnableESXIdentity then + retrivedInfo.owner = result2[1].firstname .. ' ' .. result2[1].lastname + else + retrivedInfo.owner = result2[1].name + end + cb(retrivedInfo) + end) + else + cb(retrivedInfo) + end + end) end) ESX.RegisterServerCallback('esx_policejob:getVehicleFromPlate', function(source, cb, plate) @@ -344,10 +262,20 @@ ESX.RegisterServerCallback('esx_policejob:getVehicleFromPlate', function(source, }, function(result) if result[1] ~= nil then - local playerName = ESX.GetPlayerFromIdentifier(result[1].owner).name - cb(playerName, true) + + MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier', { + ['@identifier'] = result[1].owner + }, function(result2) + + if Config.EnableESXIdentity then + cb(result2[1].firstname .. ' ' .. result2[1].lastname, true) + else + cb(result2[1].name, true) + end + + end) else - cb('unknown', false) + cb(_U('unknown'), false) end end )