Closes #130, updated to support new vehicle db system

This commit is contained in:
ElPumpo
2018-07-25 12:11:04 +02:00
parent b3a8b6ddb5
commit 5926584595
11 changed files with 83 additions and 143 deletions
+27 -31
View File
@@ -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)
+10 -2
View File
@@ -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 = {
}
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',
+1
View File
@@ -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',
+1
View File
@@ -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',
+1
View File
@@ -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',
+1
View File
@@ -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',
+34 -106
View File
@@ -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
)