context implementation (policejob) (#758)

This commit is contained in:
Taavi
2022-12-20 21:52:30 +08:00
committed by GitHub
parent 6ffecabaf2
commit 1e4f2293c2
2 changed files with 338 additions and 382 deletions
+258 -286
View File
@@ -50,30 +50,38 @@ function OpenCloakroomMenu()
local grade = ESX.PlayerData.job.grade_name local grade = ESX.PlayerData.job.grade_name
local elements = { local elements = {
{label = TranslateCap('citizen_wear'), value = 'citizen_wear'}, {unselectable = true, icon = "fas fa-shirt", title = TranslateCap("cloakroom")},
{label = TranslateCap('bullet_wear'), uniform = 'bullet_wear'}, {icon = "fas fa-shirt", title = TranslateCap('citizen_wear'), value = 'citizen_wear'},
{label = TranslateCap('gilet_wear'), uniform = 'gilet_wear'}, {icon = "fas fa-shirt", title = TranslateCap('bullet_wear'), uniform = 'bullet_wear'},
{label = TranslateCap('police_wear'), uniform = grade} {icon = "fas fa-shirt", title = TranslateCap('gilet_wear'), uniform = 'gilet_wear'},
{icon = "fas fa-shirt", title = TranslateCap('police_wear'), uniform = grade}
} }
if Config.EnableCustomPeds then if Config.EnableCustomPeds then
for k,v in ipairs(Config.CustomPeds.shared) do for k,v in ipairs(Config.CustomPeds.shared) do
table.insert(elements, {label = v.label, value = 'freemode_ped', maleModel = v.maleModel, femaleModel = v.femaleModel}) elements[#elements+1] = {
icon = "fas fa-shirt",
title = v.label,
value = 'freemode_ped',
maleModel = v.maleModel,
femaleModel = v.femaleModel
}
end end
for k,v in ipairs(Config.CustomPeds[grade]) do for k,v in ipairs(Config.CustomPeds[grade]) do
table.insert(elements, {label = v.label, value = 'freemode_ped', maleModel = v.maleModel, femaleModel = v.femaleModel}) elements[#elements+1] = {
icon = "fas fa-shirt",
title = v.label,
value = 'freemode_ped',
maleModel = v.maleModel,
femaleModel = v.femaleModel
}
end end
end end
ESX.UI.Menu.CloseAll() ESX.OpenContext("right", elements, function(menu,element)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'cloakroom', {
title = TranslateCap('cloakroom'),
align = 'top-left',
elements = elements
}, function(data, menu)
cleanPlayer(playerPed) cleanPlayer(playerPed)
local data = {current = element}
if data.current.value == 'citizen_wear' then if data.current.value == 'citizen_wear' then
if Config.EnableCustomPeds then if Config.EnableCustomPeds then
@@ -194,9 +202,7 @@ function OpenCloakroomMenu()
end) end)
end) end)
end end
end, function(data, menu) end, function(menu)
menu.close()
CurrentAction = 'menu_cloakroom' CurrentAction = 'menu_cloakroom'
CurrentActionMsg = TranslateCap('open_cloackroom') CurrentActionMsg = TranslateCap('open_cloackroom')
CurrentActionData = {} CurrentActionData = {}
@@ -207,28 +213,24 @@ function OpenArmoryMenu(station)
local elements local elements
if Config.OxInventory then if Config.OxInventory then
exports.ox_inventory:openInventory('stash', {id = 'society_police', owner = station}) exports.ox_inventory:openInventory('stash', {id = 'society_police', owner = station})
return ESX.UI.Menu.CloseAll() return ESX.CloseContext()
else else
elements = { elements = {
{label = TranslateCap('buy_weapons'), value = 'buy_weapons'} {unselectable = true, icon = "fas fa-gun", title = TranslateCap('armory')},
{icon = "fas fa-gun", title = TranslateCap('buy_weapons'), value = 'buy_weapons'}
} }
if Config.EnableArmoryManagement then if Config.EnableArmoryManagement then
table.insert(elements, {label = TranslateCap('get_weapon'), value = 'get_weapon'}) table.insert(elements, {icon = "fas fa-gun", title = TranslateCap('get_weapon'), value = 'get_weapon'})
table.insert(elements, {label = TranslateCap('put_weapon'), value = 'put_weapon'}) table.insert(elements, {icon = "fas fa-gun", title = TranslateCap('put_weapon'), value = 'put_weapon'})
table.insert(elements, {label = TranslateCap('remove_object'), value = 'get_stock'}) table.insert(elements, {icon = "fas fa-box", title = TranslateCap('remove_object'), value = 'get_stock'})
table.insert(elements, {label = TranslateCap('deposit_object'), value = 'put_stock'}) table.insert(elements, {icon = "fas fa-box", title = TranslateCap('deposit_object'), value = 'put_stock'})
end end
end end
ESX.UI.Menu.CloseAll() ESX.OpenContext("right", elements, function(menu,element)
local data = {current = element}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory', {
title = TranslateCap('armory'),
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value == 'get_weapon' then if data.current.value == 'get_weapon' then
OpenGetWeaponMenu() OpenGetWeaponMenu()
elseif data.current.value == 'put_weapon' then elseif data.current.value == 'put_weapon' then
@@ -240,10 +242,7 @@ function OpenArmoryMenu(station)
elseif data.current.value == 'get_stock' then elseif data.current.value == 'get_stock' then
OpenGetStocksMenu() OpenGetStocksMenu()
end end
end, function(menu)
end, function(data, menu)
menu.close()
CurrentAction = 'menu_armory' CurrentAction = 'menu_armory'
CurrentActionMsg = TranslateCap('open_armory') CurrentActionMsg = TranslateCap('open_armory')
CurrentActionData = {station = station} CurrentActionData = {station = station}
@@ -251,39 +250,41 @@ function OpenArmoryMenu(station)
end end
function OpenPoliceActionsMenu() function OpenPoliceActionsMenu()
ESX.UI.Menu.CloseAll() local elements = {
{unselectable = true, icon = "fas fa-police", title = "Police"},
{icon = "fas fa-user", title = TranslateCap('citizen_interaction'), value = 'citizen_interaction'},
{icon = "fas fa-car", title = TranslateCap('vehicle_interaction'), value = 'vehicle_interaction'},
{icon = "fas fa-object", title = TranslateCap('object_spawner'), value = 'object_spawner'}
}
ESX.OpenContext("right", elements, function(menu,element)
local data = {current = element}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'police_actions', {
title = 'Police',
align = 'top-left',
elements = {
{label = TranslateCap('citizen_interaction'), value = 'citizen_interaction'},
{label = TranslateCap('vehicle_interaction'), value = 'vehicle_interaction'},
{label = TranslateCap('object_spawner'), value = 'object_spawner'}
}}, function(data, menu)
if data.current.value == 'citizen_interaction' then if data.current.value == 'citizen_interaction' then
local elements = { local elements2 = {
{label = TranslateCap('id_card'), value = 'identity_card'}, {unselectable = true, icon = "fas fa-user", title = element.title},
{label = TranslateCap('search'), value = 'search'}, {icon = "fas fa-idkyet", title = TranslateCap('id_card'), value = 'identity_card'},
{label = TranslateCap('handcuff'), value = 'handcuff'}, {icon = "fas fa-idkyet", title = TranslateCap('search'), value = 'search'},
{label = TranslateCap('drag'), value = 'drag'}, {icon = "fas fa-idkyet", title = TranslateCap('handcuff'), value = 'handcuff'},
{label = TranslateCap('put_in_vehicle'), value = 'put_in_vehicle'}, {icon = "fas fa-idkyet", title = TranslateCap('drag'), value = 'drag'},
{label = TranslateCap('out_the_vehicle'), value = 'out_the_vehicle'}, {icon = "fas fa-idkyet", title = TranslateCap('put_in_vehicle'), value = 'put_in_vehicle'},
{label = TranslateCap('fine'), value = 'fine'}, {icon = "fas fa-idkyet", title = TranslateCap('out_the_vehicle'), value = 'out_the_vehicle'},
{label = TranslateCap('unpaid_bills'), value = 'unpaid_bills'} {icon = "fas fa-idkyet", title = TranslateCap('fine'), value = 'fine'},
{icon = "fas fa-idkyet", title = TranslateCap('unpaid_bills'), value = 'unpaid_bills'}
} }
if Config.EnableLicenses then if Config.EnableLicenses then
table.insert(elements, {label = TranslateCap('license_check'), value = 'license'}) elements2[#elements2+1] = {
icon = "fas fa-scroll",
title = TranslateCap('license_check'),
value = 'license'
}
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', { ESX.OpenContext("right", elements2, function(menu2,element2)
title = TranslateCap('citizen_interaction'),
align = 'top-left',
elements = elements
}, function(data2, menu2)
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer ~= -1 and closestDistance <= 3.0 then if closestPlayer ~= -1 and closestDistance <= 3.0 then
local data2 = {current = element2}
local action = data2.current.value local action = data2.current.value
if action == 'identity_card' then if action == 'identity_card' then
@@ -308,33 +309,36 @@ function OpenPoliceActionsMenu()
else else
ESX.ShowNotification(TranslateCap('no_players_nearby')) ESX.ShowNotification(TranslateCap('no_players_nearby'))
end end
end, function(data2, menu2) end, function(menu)
menu2.close() OpenPoliceActionsMenu()
end) end)
elseif data.current.value == 'vehicle_interaction' then elseif data.current.value == 'vehicle_interaction' then
local elements = {} local elements3 = {
{unselectable = true, icon = "fas fa-car", title = element.title}
}
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection() local vehicle = ESX.Game.GetVehicleInDirection()
if DoesEntityExist(vehicle) then if DoesEntityExist(vehicle) then
table.insert(elements, {label = TranslateCap('vehicle_info'), value = 'vehicle_infos'}) elements3[#elements3+1] = {icon = "fas fa-car", title = TranslateCap('vehicle_info'), value = 'vehicle_infos'}
table.insert(elements, {label = TranslateCap('pick_lock'), value = 'hijack_vehicle'}) elements3[#elements3+1] = {icon = "fas fa-car", title = TranslateCap('pick_lock'), value = 'hijack_vehicle'}
table.insert(elements, {label = TranslateCap('impound'), value = 'impound'}) elements3[#elements3+1] = {icon = "fas fa-car", title = TranslateCap('impound'), value = 'impound'}
end end
table.insert(elements, {label = TranslateCap('search_database'), value = 'search_database'}) elements3[#elements3+1] = {
icon = "fas fa-scroll",
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_interaction', { title = TranslateCap('search_database'),
title = TranslateCap('vehicle_interaction'), value = 'search_database'
align = 'top-left', }
elements = elements
}, function(data2, menu2) ESX.OpenContext("right", elements3, function(menu3,element3)
local data2 = {current = element3}
local coords = GetEntityCoords(playerPed) local coords = GetEntityCoords(playerPed)
vehicle = ESX.Game.GetVehicleInDirection() vehicle = ESX.Game.GetVehicleInDirection()
action = data2.current.value action = data2.current.value
if action == 'search_database' then if action == 'search_database' then
LookupVehicle() LookupVehicle(element3)
elseif DoesEntityExist(vehicle) then elseif DoesEntityExist(vehicle) then
if action == 'vehicle_infos' then if action == 'vehicle_infos' then
local vehicleData = ESX.Game.GetVehicleProperties(vehicle) local vehicleData = ESX.Game.GetVehicleProperties(vehicle)
@@ -350,7 +354,6 @@ function OpenPoliceActionsMenu()
ESX.ShowNotification(TranslateCap('vehicle_unlocked')) ESX.ShowNotification(TranslateCap('vehicle_unlocked'))
end end
elseif action == 'impound' then elseif action == 'impound' then
-- is the script busy?
if currentTask.busy then if currentTask.busy then
return return
end end
@@ -362,10 +365,9 @@ function OpenPoliceActionsMenu()
currentTask.task = ESX.SetTimeout(10000, function() currentTask.task = ESX.SetTimeout(10000, function()
ClearPedTasks(playerPed) ClearPedTasks(playerPed)
ImpoundVehicle(vehicle) ImpoundVehicle(vehicle)
Wait(100) -- sleep the entire script to let stuff sink back to reality Wait(100)
end) end)
-- keep track of that vehicle!
CreateThread(function() CreateThread(function()
while currentTask.busy do while currentTask.busy do
Wait(1000) Wait(1000)
@@ -384,21 +386,21 @@ function OpenPoliceActionsMenu()
else else
ESX.ShowNotification(TranslateCap('no_vehicles_nearby')) ESX.ShowNotification(TranslateCap('no_vehicles_nearby'))
end end
end, function(menu)
end, function(data2, menu2) OpenPoliceActionsMenu()
menu2.close()
end) end)
elseif data.current.value == 'object_spawner' then elseif data.current.value == "object_spawner" then
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', { local elements4 = {
title = TranslateCap('traffic_interaction'), {unselectable = true, icon = "fas fa-object", title = element.title},
align = 'top-left', {icon = "fas fa-cone", title = TranslateCap('cone'), model = 'prop_roadcone02a'},
elements = { {icon = "fas fa-cone", title = TranslateCap('barrier'), model = 'prop_barrier_work05'},
{label = TranslateCap('cone'), model = 'prop_roadcone02a'}, {icon = "fas fa-cone", title = TranslateCap('spikestrips'), model = 'p_ld_stinger_s'},
{label = TranslateCap('barrier'), model = 'prop_barrier_work05'}, {icon = "fas fa-cone", title = TranslateCap('box'), model = 'prop_boxpile_07d'},
{label = TranslateCap('spikestrips'), model = 'p_ld_stinger_s'}, {icon = "fas fa-cone", title = TranslateCap('cash'), model = 'hei_prop_cash_crate_half_full'}
{label = TranslateCap('box'), model = 'prop_boxpile_07d'}, }
{label = TranslateCap('cash'), model = 'hei_prop_cash_crate_half_full'}
}}, function(data2, menu2) ESX.OpenContext("right", elements4, function(menu4,element4)
local data2 = {current = element4}
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local coords, forward = GetEntityCoords(playerPed), GetEntityForwardVector(playerPed) local coords, forward = GetEntityCoords(playerPed), GetEntityForwardVector(playerPed)
local objectCoords = (coords + forward * 1.0) local objectCoords = (coords + forward * 1.0)
@@ -407,46 +409,40 @@ function OpenPoliceActionsMenu()
SetEntityHeading(obj, GetEntityHeading(playerPed)) SetEntityHeading(obj, GetEntityHeading(playerPed))
PlaceObjectOnGroundProperly(obj) PlaceObjectOnGroundProperly(obj)
end) end)
end, function(data2, menu2) end, function(menu)
menu2.close() OpenPoliceActionsMenu()
end) end)
end end
end, function(data, menu)
menu.close()
end) end)
end end
function OpenIdentityCardMenu(player) function OpenIdentityCardMenu(player)
ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data) ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data)
local elements = { local elements = {
{label = TranslateCap('name', data.name)}, {icon = "fas fa-user", title = TranslateCap('name', data.name)},
{label = TranslateCap('job', ('%s - %s'):format(data.job, data.grade))} {icon = "fas fa-user", title = TranslateCap('job', ('%s - %s'):format(data.job, data.grade))}
} }
if Config.EnableESXIdentity then if Config.EnableESXIdentity then
table.insert(elements, {label = TranslateCap('sex', TranslateCap(data.sex))}) elements[#elements+1] = {icon = "fas fa-user", title = TranslateCap('sex', TranslateCap(data.sex))}
table.insert(elements, {label = TranslateCap('dob', data.dob)}) elements[#elements+1] = {icon = "fas fa-user", title = TranslateCap('sex', TranslateCap(data.sex))}
table.insert(elements, {label = TranslateCap('height', data.height)}) elements[#elements+1] = {icon = "fas fa-user", title = TranslateCap('height', data.height)}
end end
if Config.EnableESXOptionalneeds and data.drunk then if Config.EnableESXOptionalneeds and data.drunk then
table.insert(elements, {label = TranslateCap('bac', data.drunk)}) elements[#elements+1] = {title = TranslateCap('bac', data.drunk)}
end end
if data.licenses then if data.licenses then
table.insert(elements, {label = TranslateCap('license_label')}) elements[#elements+1] = {title = TranslateCap('license_label')}
for i=1, #data.licenses, 1 do for i=1, #data.licenses, 1 do
table.insert(elements, {label = data.licenses[i].label}) elements[#elements+1] = {title = data.licenses[i].label}
end end
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', { ESX.OpenContext("right", elements, nil, function(menu)
title = TranslateCap('citizen_interaction'), OpenPoliceActionsMenu()
align = 'top-left',
elements = elements
}, nil, function(data, menu)
menu.close()
end) end)
end, GetPlayerServerId(player)) end, GetPlayerServerId(player))
end end
@@ -454,21 +450,23 @@ end
function OpenBodySearchMenu(player) function OpenBodySearchMenu(player)
if Config.OxInventory then if Config.OxInventory then
exports.ox_inventory:openInventory('player', GetPlayerServerId(player)) exports.ox_inventory:openInventory('player', GetPlayerServerId(player))
return ESX.UI.Menu.CloseAll() return ESX.CloseContext()
end end
ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data) ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data)
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-user", title = TranslateCap('search')}
}
for i=1, #data.accounts, 1 do for i=1, #data.accounts, 1 do
if data.accounts[i].name == 'black_money' and data.accounts[i].money > 0 then if data.accounts[i].name == 'black_money' and data.accounts[i].money > 0 then
table.insert(elements, { elements[#elements+1] = {
label = TranslateCap('confiscate_dirty', ESX.Math.Round(data.accounts[i].money)), icon = "fas fa-money",
title = TranslateCap('confiscate_dirty', ESX.Math.Round(data.accounts[i].money)),
value = 'black_money', value = 'black_money',
itemType = 'item_account', itemType = 'item_account',
amount = data.accounts[i].money amount = data.accounts[i].money
}) }
break break
end end
end end
@@ -476,78 +474,72 @@ function OpenBodySearchMenu(player)
table.insert(elements, {label = TranslateCap('guns_label')}) table.insert(elements, {label = TranslateCap('guns_label')})
for i=1, #data.weapons, 1 do for i=1, #data.weapons, 1 do
table.insert(elements, { elements[#elements+1] = {
label = TranslateCap('confiscate_weapon', ESX.GetWeaponLabel(data.weapons[i].name), data.weapons[i].ammo), icon = "fas fa-gun",
title = TranslateCap('confiscate_weapon', ESX.GetWeaponLabel(data.weapons[i].name), data.weapons[i].ammo),
value = data.weapons[i].name, value = data.weapons[i].name,
itemType = 'item_weapon', itemType = 'item_weapon',
amount = data.weapons[i].ammo amount = data.weapons[i].ammo
}) }
end end
table.insert(elements, {label = TranslateCap('inventory_label')}) elements[#elements+1] = {title = TranslateCap('inventory_label')}
for i=1, #data.inventory, 1 do for i=1, #data.inventory, 1 do
if data.inventory[i].count > 0 then if data.inventory[i].count > 0 then
table.insert(elements, { elements[#elements+1] = {
label = TranslateCap('confiscate_inv', data.inventory[i].count, data.inventory[i].label), icon = "fas fa-box",
title = TranslateCap('confiscate_inv', data.inventory[i].count, data.inventory[i].label),
value = data.inventory[i].name, value = data.inventory[i].name,
itemType = 'item_standard', itemType = 'item_standard',
amount = data.inventory[i].count amount = data.inventory[i].count
}) }
end end
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'body_search', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('search'), local data = {current = element}
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value then if data.current.value then
TriggerServerEvent('esx_policejob:confiscatePlayerItem', GetPlayerServerId(player), data.current.itemType, data.current.value, data.current.amount) TriggerServerEvent('esx_policejob:confiscatePlayerItem', GetPlayerServerId(player), data.current.itemType, data.current.value, data.current.amount)
OpenBodySearchMenu(player) OpenBodySearchMenu(player)
end end
end, function(data, menu)
menu.close()
end) end)
end, GetPlayerServerId(player)) end, GetPlayerServerId(player))
end end
function OpenFineMenu(player) function OpenFineMenu(player)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'fine', { local elements = {
title = TranslateCap('fine'), {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')},
align = 'top-left', {icon = "fas fa-scroll", title = TranslateCap('traffic_offense'), value = 0},
elements = { {icon = "fas fa-scroll", title = TranslateCap('minor_offense'), value = 1},
{label = TranslateCap('traffic_offense'), value = 0}, {icon = "fas fa-scroll", title = TranslateCap('average_offense'), value = 2},
{label = TranslateCap('minor_offense'), value = 1}, {icon = "fas fa-scroll", title = TranslateCap('major_offense'), value = 3}
{label = TranslateCap('average_offense'), value = 2}, }
{label = TranslateCap('major_offense'), value = 3}
}}, function(data, menu) ESX.OpenContext("right", elements, function(menu,element)
local data = {current = element}
OpenFineCategoryMenu(player, data.current.value) OpenFineCategoryMenu(player, data.current.value)
end, function(data, menu)
menu.close()
end) end)
end end
function OpenFineCategoryMenu(player, category) function OpenFineCategoryMenu(player, category)
ESX.TriggerServerCallback('esx_policejob:getFineList', function(fines) ESX.TriggerServerCallback('esx_policejob:getFineList', function(fines)
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')}
}
for k,fine in ipairs(fines) do for k,fine in ipairs(fines) do
table.insert(elements, { elements[#elements+1] = {
label = ('%s <span style="color:green;">%s</span>'):format(fine.label, TranslateCap('armory_item', ESX.Math.GroupDigits(fine.amount))), icon = "fas fa-scroll",
title = ('%s <span style="color:green;">%s</span>'):format(fine.label, TranslateCap('armory_item', ESX.Math.GroupDigits(fine.amount))),
value = fine.id, value = fine.id,
amount = fine.amount, amount = fine.amount,
fineLabel = fine.label fineLabel = fine.label
}) }
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'fine_category', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('fine'), local data = {current = element}
align = 'top-left',
elements = elements
}, function(data, menu)
menu.close()
if Config.EnablePlayerManagement then if Config.EnablePlayerManagement then
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), 'society_police', TranslateCap('fine_total', data.current.fineLabel), data.current.amount) TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), 'society_police', TranslateCap('fine_total', data.current.fineLabel), data.current.amount)
else else
@@ -557,65 +549,63 @@ function OpenFineCategoryMenu(player, category)
ESX.SetTimeout(300, function() ESX.SetTimeout(300, function()
OpenFineCategoryMenu(player, category) OpenFineCategoryMenu(player, category)
end) end)
end, function(data, menu)
menu.close()
end) end)
end, category) end, category)
end end
function LookupVehicle() function LookupVehicle(elementF)
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'lookup_vehicle', { local elements = {
title = TranslateCap('search_database_title'), {unselectable = true, icon = "fas fa-car", title = elementF.title},
}, function(data, menu) {title = "Enter Plate", input = true, inputType = "text", inputPlaceholder = "ABC 123"},
{icon = "fas fa-check-double", title = "Lookup Plate", value = "lookup"}
}
ESX.OpenContext("right", elements, function(menu,element)
local data = {value = menu.eles[2].inputValue}
local length = string.len(data.value) local length = string.len(data.value)
if not data.value or length < 2 or length > 8 then if not data.value or length < 2 or length > 8 then
ESX.ShowNotification(TranslateCap('search_database_error_invalid')) ESX.ShowNotification(TranslateCap('search_database_error_invalid'))
else else
ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo) ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo)
local elements = {{label = TranslateCap('plate', retrivedInfo.plate)}} local elements = {
menu.close() {unselectable = true, icon = "fas fa-car", title = element.title},
{unselectable = true, icon = "fas fa-car", title = TranslateCap('plate', retrivedInfo.plate)}
}
if not retrivedInfo.owner then if not retrivedInfo.owner then
table.insert(elements, {label = TranslateCap('owner_unknown')}) elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner_unknown')}
else else
table.insert(elements, {label = TranslateCap('owner', retrivedInfo.owner)}) elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner', retrivedInfo.owner)}
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_infos', { ESX.OpenContext("right", elements, nil, function(menu)
title = TranslateCap('vehicle_info'), OpenPoliceActionsMenu()
align = 'top-left',
elements = elements
}, nil, function(data2, menu2)
menu2.close()
end) end)
end, data.value) end, data.value)
end end
end, function(data, menu)
menu.close()
end) end)
end end
function ShowPlayerLicense(player) function ShowPlayerLicense(player)
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('license_revoke')}
}
ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(playerData) ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(playerData)
if playerData.licenses then if playerData.licenses then
for i=1, #playerData.licenses, 1 do for i=1, #playerData.licenses, 1 do
if playerData.licenses[i].label and playerData.licenses[i].type then if playerData.licenses[i].label and playerData.licenses[i].type then
table.insert(elements, { elements[#elements+1] = {
label = playerData.licenses[i].label, icon = "fas fa-scroll",
title = playerData.licenses[i].label,
type = playerData.licenses[i].type type = playerData.licenses[i].type
}) }
end end
end end
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'manage_license', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('license_revoke'), local data = {current = element}
align = 'top-left',
elements = elements,
}, function(data, menu)
ESX.ShowNotification(TranslateCap('licence_you_revoked', data.current.label, playerData.name)) ESX.ShowNotification(TranslateCap('licence_you_revoked', data.current.label, playerData.name))
TriggerServerEvent('esx_policejob:message', GetPlayerServerId(player), TranslateCap('license_revoked', data.current.label)) TriggerServerEvent('esx_policejob:message', GetPlayerServerId(player), TranslateCap('license_revoked', data.current.label))
@@ -624,85 +614,77 @@ function ShowPlayerLicense(player)
ESX.SetTimeout(300, function() ESX.SetTimeout(300, function()
ShowPlayerLicense(player) ShowPlayerLicense(player)
end) end)
end, function(data, menu)
menu.close()
end) end)
end, GetPlayerServerId(player)) end, GetPlayerServerId(player))
end end
function OpenUnpaidBillsMenu(player) function OpenUnpaidBillsMenu(player)
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('unpaid_bills')}
}
ESX.TriggerServerCallback('esx_billing:getTargetBills', function(bills) ESX.TriggerServerCallback('esx_billing:getTargetBills', function(bills)
for k,bill in ipairs(bills) do for k,bill in ipairs(bills) do
table.insert(elements, { elements[#elements+1] = {
label = ('%s - <span style="color:red;">%s</span>'):format(bill.label, TranslateCap('armory_item', ESX.Math.GroupDigits(bill.amount))), unselectable = true,
icon = "fas fa-scroll",
title = ('%s - <span style="color:red;">%s</span>'):format(bill.label, TranslateCap('armory_item', ESX.Math.GroupDigits(bill.amount))),
billId = bill.id billId = bill.id
}) }
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'billing', { ESX.OpenContext("right", elements, nil, nil)
title = TranslateCap('unpaid_bills'),
align = 'top-left',
elements = elements
}, nil, function(data, menu)
menu.close()
end)
end, GetPlayerServerId(player)) end, GetPlayerServerId(player))
end end
function OpenVehicleInfosMenu(vehicleData) function OpenVehicleInfosMenu(vehicleData)
ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo) ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo)
local elements = {{label = TranslateCap('plate', retrivedInfo.plate)}} local elements = {
{unselectable = true, icon = "fas fa-car", title = TranslateCap('vehicle_info')},
{icon = "fas fa-car", title = TranslateCap('plate', retrivedInfo.plate)}
}
if not retrivedInfo.owner then if not retrivedInfo.owner then
table.insert(elements, {label = TranslateCap('owner_unknown')}) elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner_unknown')}
else else
table.insert(elements, {label = TranslateCap('owner', retrivedInfo.owner)}) elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner', retrivedInfo.owner)}
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_infos', { ESX.OpenContext("right", elements, nil, nil)
title = TranslateCap('vehicle_info'),
align = 'top-left',
elements = elements
}, nil, function(data, menu)
menu.close()
end)
end, vehicleData.plate) end, vehicleData.plate)
end end
function OpenGetWeaponMenu() function OpenGetWeaponMenu()
ESX.TriggerServerCallback('esx_policejob:getArmoryWeapons', function(weapons) ESX.TriggerServerCallback('esx_policejob:getArmoryWeapons', function(weapons)
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-gun", title = TranslateCap('get_weapon_menu')}
}
for i=1, #weapons, 1 do for i=1, #weapons, 1 do
if weapons[i].count > 0 then if weapons[i].count > 0 then
table.insert(elements, { elements[#elements+1] = {
label = 'x' .. weapons[i].count .. ' ' .. ESX.GetWeaponLabel(weapons[i].name), icon = "fas fa-gun",
title = 'x' .. weapons[i].count .. ' ' .. ESX.GetWeaponLabel(weapons[i].name),
value = weapons[i].name value = weapons[i].name
}) }
end end
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_get_weapon', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('get_weapon_menu'), local data = {current = element}
align = 'top-left',
elements = elements
}, function(data, menu)
menu.close()
ESX.TriggerServerCallback('esx_policejob:removeArmoryWeapon', function() ESX.TriggerServerCallback('esx_policejob:removeArmoryWeapon', function()
ESX.CloseContext()
OpenGetWeaponMenu() OpenGetWeaponMenu()
end, data.current.value) end, data.current.value)
end, function(data, menu)
menu.close()
end) end)
end) end)
end end
function OpenPutWeaponMenu() function OpenPutWeaponMenu()
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-gun", title = TranslateCap('put_weapon_menu')}
}
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local weaponList = ESX.GetWeaponList() local weaponList = ESX.GetWeaponList()
@@ -710,30 +692,27 @@ function OpenPutWeaponMenu()
local weaponHash = joaat(weaponList[i].name) local weaponHash = joaat(weaponList[i].name)
if HasPedGotWeapon(playerPed, weaponHash, false) and weaponList[i].name ~= 'WEAPON_UNARMED' then if HasPedGotWeapon(playerPed, weaponHash, false) and weaponList[i].name ~= 'WEAPON_UNARMED' then
table.insert(elements, { elements[#elements+1] = {
label = weaponList[i].label, icon = "fas fa-gun",
title = weaponList[i].label,
value = weaponList[i].name value = weaponList[i].name
}) }
end end
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_put_weapon', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('put_weapon_menu'), local data = {current = element}
align = 'top-left',
elements = elements
}, function(data, menu)
menu.close()
ESX.TriggerServerCallback('esx_policejob:addArmoryWeapon', function() ESX.TriggerServerCallback('esx_policejob:addArmoryWeapon', function()
ESX.CloseContext()
OpenPutWeaponMenu() OpenPutWeaponMenu()
end, data.current.value, true) end, data.current.value, true)
end, function(data, menu)
menu.close()
end) end)
end end
function OpenBuyWeaponsMenu() function OpenBuyWeaponsMenu()
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-gun", title = TranslateCap('armory_weapontitle')}
}
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
for k,v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job.grade_name]) do for k,v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job.grade_name]) do
@@ -757,15 +736,16 @@ function OpenBuyWeaponsMenu()
end end
end end
table.insert(components, { components[#components+1] = {
label = label, icon = "fas fa-gun",
title = label,
componentLabel = component.label, componentLabel = component.label,
hash = component.hash, hash = component.hash,
name = component.name, name = component.name,
price = v.components[i], price = v.components[i],
hasComponent = hasComponent, hasComponent = hasComponent,
componentNum = i componentNum = i
}) }
end end
end end
end end
@@ -782,21 +762,19 @@ function OpenBuyWeaponsMenu()
end end
end end
table.insert(elements, { elements[#elements+1] = {
label = label, icon = "fas fa-gun",
title = label,
weaponLabel = weapon.label, weaponLabel = weapon.label,
name = weapon.name, name = weapon.name,
components = components, components = components,
price = v.price, price = v.price,
hasWeapon = hasWeapon hasWeapon = hasWeapon
}) }
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_buy_weapons', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('armory_weapontitle'), local data = {current = element}
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.hasWeapon then if data.current.hasWeapon then
if #data.current.components > 0 then if #data.current.components > 0 then
OpenWeaponComponentShop(data.current.components, data.current.name, menu) OpenWeaponComponentShop(data.current.components, data.current.name, menu)
@@ -815,17 +793,13 @@ function OpenBuyWeaponsMenu()
end end
end, data.current.name, 1) end, data.current.name, 1)
end end
end, function(data, menu)
menu.close()
end) end)
end end
function OpenWeaponComponentShop(components, weaponName, parentShop) function OpenWeaponComponentShop(components, weaponName, parentShop)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_buy_weapons_components', {
title = TranslateCap('armory_componenttitle'), ESX.OpenContext("right", components, function(menu,element)
align = 'top-left', local data = {current = element}
elements = components
}, function(data, menu)
if data.current.hasComponent then if data.current.hasComponent then
ESX.ShowNotification(TranslateCap('armory_hascomponent')) ESX.ShowNotification(TranslateCap('armory_hascomponent'))
else else
@@ -843,96 +817,94 @@ function OpenWeaponComponentShop(components, weaponName, parentShop)
end end
end, weaponName, 2, data.current.componentNum) end, weaponName, 2, data.current.componentNum)
end end
end, function(data, menu)
menu.close()
end) end)
end end
function OpenGetStocksMenu() function OpenGetStocksMenu()
ESX.TriggerServerCallback('esx_policejob:getStockItems', function(items) ESX.TriggerServerCallback('esx_policejob:getStockItems', function(items)
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-box", title = TranslateCap('police_stock')}
}
for i=1, #items, 1 do for i=1, #items, 1 do
table.insert(elements, { elements[#elements+1] = {
label = 'x' .. items[i].count .. ' ' .. items[i].label, icon = "fas fa-box",
title = 'x' .. items[i].count .. ' ' .. items[i].label,
value = items[i].name value = items[i].name
}) }
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('police_stock'), local data = {current = element}
align = 'top-left',
elements = elements
}, function(data, menu)
local itemName = data.current.value local itemName = data.current.value
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', { local elements2 = {
title = TranslateCap('quantity') {unselectable = true, icon = "fas fa-box", title = element.title},
}, function(data2, menu2) {title = TranslateCap('quantity'), input = true, inputType = "number", inputMin = 1, inputMax = 150, inputPlaceholder = "Amount to withdraw.."},
{icon = "fas fa-check-double", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local data2 = {value = menu2.eles[2].inputValue}
local count = tonumber(data2.value) local count = tonumber(data2.value)
if not count then if not count then
ESX.ShowNotification(TranslateCap('quantity_invalid')) ESX.ShowNotification(TranslateCap('quantity_invalid'))
else else
menu2.close() ESX.CloseContext()
menu.close()
TriggerServerEvent('esx_policejob:getStockItem', itemName, count) TriggerServerEvent('esx_policejob:getStockItem', itemName, count)
Wait(300) Wait(300)
OpenGetStocksMenu() OpenGetStocksMenu()
end end
end, function(data2, menu2)
menu2.close()
end) end)
end, function(data, menu)
menu.close()
end) end)
end) end)
end end
function OpenPutStocksMenu() function OpenPutStocksMenu()
ESX.TriggerServerCallback('esx_policejob:getPlayerInventory', function(inventory) ESX.TriggerServerCallback('esx_policejob:getPlayerInventory', function(inventory)
local elements = {} local elements = {
{unselectable = true, icon = "fas fa-box", title = TranslateCap('inventory')}
}
for i=1, #inventory.items, 1 do for i=1, #inventory.items, 1 do
local item = inventory.items[i] local item = inventory.items[i]
if item.count > 0 then if item.count > 0 then
table.insert(elements, { elements[#elements+1] = {
label = item.label .. ' x' .. item.count, icon = "fas fa-box",
title = item.label .. ' x' .. item.count,
type = 'item_standard', type = 'item_standard',
value = item.name value = item.name
}) }
end end
end end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('inventory'), local data = {current = element}
align = 'top-left',
elements = elements
}, function(data, menu)
local itemName = data.current.value local itemName = data.current.value
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count', { local elements2 = {
title = TranslateCap('quantity') {unselectable = true, icon = "fas fa-box", title = element.title},
}, function(data2, menu2) {title = TranslateCap('quantity'), input = true, inputType = "number", inputMin = 1, inputMax = 150, inputPlaceholder = "Amount to withdraw.."},
{icon = "fas fa-check-double", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local data2 = {value = menu2.eles[2].inputValue}
local count = tonumber(data2.value) local count = tonumber(data2.value)
if not count then if not count then
ESX.ShowNotification(TranslateCap('quantity_invalid')) ESX.ShowNotification(TranslateCap('quantity_invalid'))
else else
menu2.close() ESX.CloseContext()
menu.close()
TriggerServerEvent('esx_policejob:putStockItems', itemName, count) TriggerServerEvent('esx_policejob:putStockItems', itemName, count)
Wait(300) Wait(300)
OpenPutStocksMenu() OpenPutStocksMenu()
end end
end, function(data2, menu2)
menu2.close()
end) end)
end, function(data, menu)
menu.close()
end) end)
end) end)
end end
@@ -993,7 +965,7 @@ end)
AddEventHandler('esx_policejob:hasExitedMarker', function(station, part, partNum) AddEventHandler('esx_policejob:hasExitedMarker', function(station, part, partNum)
if not isInShopMenu then if not isInShopMenu then
ESX.UI.Menu.CloseAll() ESX.CloseContext()
end end
CurrentAction = nil CurrentAction = nil
@@ -1437,7 +1409,7 @@ ESX.RegisterInput("police:interact", "(ESX PoliceJob) Interact", "keyboard", "E"
elseif CurrentAction == 'delete_vehicle' then elseif CurrentAction == 'delete_vehicle' then
ESX.Game.DeleteVehicle(CurrentActionData.vehicle) ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
elseif CurrentAction == 'menu_boss_actions' then elseif CurrentAction == 'menu_boss_actions' then
ESX.UI.Menu.CloseAll() ESX.CloseContext()
TriggerEvent('esx_society:openBossMenu', 'police', function(data, menu) TriggerEvent('esx_society:openBossMenu', 'police', function(data, menu)
menu.close() menu.close()
+80 -96
View File
@@ -3,16 +3,15 @@ local spawnedVehicles = {}
function OpenVehicleSpawnerMenu(type, station, part, partNum) function OpenVehicleSpawnerMenu(type, station, part, partNum)
local playerCoords = GetEntityCoords(PlayerPedId()) local playerCoords = GetEntityCoords(PlayerPedId())
local elements = {
{unselectable = true, icon = "fas fa-car", title = TranslateCap('garage_title')},
{icon = "fas fa-car", title = TranslateCap('garage_storeditem'), action = 'garage'},
{icon = "fas fa-car", title = TranslateCap('garage_storeitem'), action = 'store_garage'},
{icon = "fas fa-car", title = TranslateCap('garage_buyitem'), action = 'buy_vehicle'}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle', { ESX.OpenContext("right", elements, function(menu,element)
title = TranslateCap('garage_title'), if element.action == "buy_vehicle" then
align = 'top-left',
elements = {
{label = TranslateCap('garage_storeditem'), action = 'garage'},
{label = TranslateCap('garage_storeitem'), action = 'store_garage'},
{label = TranslateCap('garage_buyitem'), action = 'buy_vehicle'}
}}, function(data, menu)
if data.current.action == 'buy_vehicle' then
local shopElements = {} local shopElements = {}
local shopCoords = Config.PoliceStations[station][part][partNum].InsideShop local shopCoords = Config.PoliceStations[station][part][partNum].InsideShop
local authorizedVehicles = Config.AuthorizedVehicles[type][ESX.PlayerData.job.grade_name] local authorizedVehicles = Config.AuthorizedVehicles[type][ESX.PlayerData.job.grade_name]
@@ -23,14 +22,15 @@ function OpenVehicleSpawnerMenu(type, station, part, partNum)
if IsModelInCdimage(vehicle.model) then if IsModelInCdimage(vehicle.model) then
local vehicleLabel = GetLabelText(GetDisplayNameFromVehicleModel(vehicle.model)) local vehicleLabel = GetLabelText(GetDisplayNameFromVehicleModel(vehicle.model))
table.insert(shopElements, { shopElements[#shopElements+1] = {
label = ('%s - <span style="color:green;">%s</span>'):format(vehicleLabel, TranslateCap('shop_item', ESX.Math.GroupDigits(vehicle.price))), icon = 'fas fa-car',
title = ('%s - <span style="color:green;">%s</span>'):format(vehicleLabel, TranslateCap('shop_item', ESX.Math.GroupDigits(vehicle.price))),
name = vehicleLabel, name = vehicleLabel,
model = vehicle.model, model = vehicle.model,
price = vehicle.price, price = vehicle.price,
props = vehicle.props, props = vehicle.props,
type = type type = type
}) }
end end
end end
@@ -45,8 +45,10 @@ function OpenVehicleSpawnerMenu(type, station, part, partNum)
else else
ESX.ShowNotification(TranslateCap('garage_notauthorized')) ESX.ShowNotification(TranslateCap('garage_notauthorized'))
end end
elseif data.current.action == 'garage' then elseif element.action == "garage" then
local garage = {} local garage = {
{unselectable = true, icon = "fas fa-car", title = "Garage"}
}
ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles) ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles)
if #jobVehicles > 0 then if #jobVehicles > 0 then
@@ -65,42 +67,37 @@ function OpenVehicleSpawnerMenu(type, station, part, partNum)
label = label .. ('<span style="color:darkred;">%s</span>'):format(TranslateCap('garage_notstored')) label = label .. ('<span style="color:darkred;">%s</span>'):format(TranslateCap('garage_notstored'))
end end
table.insert(garage, { garage[#garage+1] = {
label = label, icon = 'fas fa-car',
title = label,
stored = v.stored, stored = v.stored,
model = props.model, model = props.model,
plate = props.plate plate = props.plate
}) }
allVehicleProps[props.plate] = props allVehicleProps[props.plate] = props
end end
end end
if #garage > 0 then if #garage > 0 then
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_garage', { ESX.OpenContext("right", garage, function(menuG,elementG)
title = TranslateCap('garage_title'), if elementG.stored == 1 then
align = 'top-left',
elements = garage
}, function(data2, menu2)
if data2.current.stored == 1 then
local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(station, part, partNum) local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(station, part, partNum)
if foundSpawn then if foundSpawn then
menu2.close() ESX.CloseContext()
ESX.Game.SpawnVehicle(data2.current.model, spawnPoint.coords, spawnPoint.heading, function(vehicle) ESX.Game.SpawnVehicle(elementG.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
local vehicleProps = allVehicleProps[data2.current.plate] local vehicleProps = allVehicleProps[elementG.plate]
ESX.Game.SetVehicleProperties(vehicle, vehicleProps) ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
TriggerServerEvent('esx_vehicleshop:setJobVehicleState', data2.current.plate, false) TriggerServerEvent('esx_vehicleshop:setJobVehicleState', elementG.plate, false)
ESX.ShowNotification(TranslateCap('garage_released')) ESX.ShowNotification(TranslateCap('garage_released'))
end) end)
end end
else else
ESX.ShowNotification(TranslateCap('garage_notavailable')) ESX.ShowNotification(TranslateCap('garage_notavailable'))
end end
end, function(data2, menu2)
menu2.close()
end) end)
else else
ESX.ShowNotification(TranslateCap('garage_empty')) ESX.ShowNotification(TranslateCap('garage_empty'))
@@ -109,11 +106,9 @@ function OpenVehicleSpawnerMenu(type, station, part, partNum)
ESX.ShowNotification(TranslateCap('garage_empty')) ESX.ShowNotification(TranslateCap('garage_empty'))
end end
end, type) end, type)
elseif data.current.action == 'store_garage' then elseif element.action == "store_garage" then
StoreNearbyVehicle(playerCoords) StoreNearbyVehicle(playerCoords)
end end
end, function(data, menu)
menu.close()
end) end)
end end
@@ -207,85 +202,74 @@ end
function OpenShopMenu(elements, restoreCoords, shopCoords) function OpenShopMenu(elements, restoreCoords, shopCoords)
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
isInShopMenu = true isInShopMenu = true
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-car", title = element.title},
{icon = "fas fa-eye", title = "View", value = "view"}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop', { ESX.OpenContext("right", elements2, function(menu2,element2)
title = TranslateCap('vehicleshop_title'), if element2.value == "view" then
align = 'top-left', DeleteSpawnedVehicles()
elements = elements WaitForVehicleToLoad(element.model)
}, function(data, menu)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop_confirm', {
title = TranslateCap('vehicleshop_confirm', data.current.name, data.current.price),
align = 'top-left',
elements = {
{label = TranslateCap('confirm_no'), value = 'no'},
{label = TranslateCap('confirm_yes'), value = 'yes'}
}}, function(data2, menu2)
if data2.current.value == 'yes' then
local newPlate = exports['esx_vehicleshop']:GeneratePlate()
local vehicle = GetVehiclePedIsIn(playerPed, false)
local props = ESX.Game.GetVehicleProperties(vehicle)
props.plate = newPlate
ESX.TriggerServerCallback('esx_policejob:buyJobVehicle', function (bought) ESX.Game.SpawnLocalVehicle(element.model, shopCoords, 0.0, function(vehicle)
if bought then table.insert(spawnedVehicles, vehicle)
ESX.ShowNotification(TranslateCap('vehicleshop_bought', data.current.name, ESX.Math.GroupDigits(data.current.price))) TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(element.model)
if element.props then
ESX.Game.SetVehicleProperties(vehicle, element.props)
end
end)
local elements3 = {
{unselectable = true, icon = "fas fa-car", title = element.title},
{icon = "fas fa-check-double", title = "Buy", value = "buy"},
{icon = "fas fa-eye", title = "Stop Viewing", value = "stop"}
}
ESX.OpenContext("right", elements3, function(menu3,element3)
if element3.value == 'stop' then
isInShopMenu = false isInShopMenu = false
ESX.UI.Menu.CloseAll() ESX.CloseContext()
DeleteSpawnedVehicles() DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false) FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true) SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords) ESX.Game.Teleport(playerPed, restoreCoords)
else elseif element3.value == "buy" then
ESX.ShowNotification(TranslateCap('vehicleshop_money')) local newPlate = exports['esx_vehicleshop']:GeneratePlate()
menu2.close() local vehicle = GetVehiclePedIsIn(playerPed, false)
local props = ESX.Game.GetVehicleProperties(vehicle)
props.plate = newPlate
ESX.TriggerServerCallback('esx_policejob:buyJobVehicle', function (bought)
if bought then
ESX.ShowNotification(TranslateCap('vehicleshop_bought', element.name, ESX.Math.GroupDigits(element.price)))
isInShopMenu = false
ESX.CloseContext()
DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords)
else
ESX.ShowNotification(TranslateCap('vehicleshop_money'))
ESX.CloseContext()
end
end, props, element.type)
end end
end, props, data.current.type) end)
else
menu2.close()
end
end, function(data2, menu2)
menu2.close()
end)
end, function(data, menu)
isInShopMenu = false
ESX.UI.Menu.CloseAll()
DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords)
end, function(data, menu)
DeleteSpawnedVehicles()
WaitForVehicleToLoad(data.current.model)
ESX.Game.SpawnLocalVehicle(data.current.model, shopCoords, 0.0, function(vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(data.current.model)
if data.current.props then
ESX.Game.SetVehicleProperties(vehicle, data.current.props)
end end
end) end)
end) end)
WaitForVehicleToLoad(elements[1].model)
ESX.Game.SpawnLocalVehicle(elements[1].model, shopCoords, 0.0, function(vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(elements[1].model)
if elements[1].props then
ESX.Game.SetVehicleProperties(vehicle, elements[1].props)
end
end)
end end
CreateThread(function() CreateThread(function()
while true do while true do
Wait(0) Wait(0)