Facebook
From main, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 37
  1. local Keys = {
  2.   ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  3.   ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  4.   ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  5.   ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  6.   ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  7.   ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  8.   ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  9.   ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  10.   ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  11. }
  12.  
  13. local PlayerData                = {}
  14. local GUI                       = {}
  15. local HasAlreadyEnteredMarker   = false
  16. local LastStation               = nil
  17. local LastPart                  = nil
  18. local LastPartNum               = nil
  19. local LastEntity                = nil
  20. local CurrentAction             = nil
  21. local CurrentActionMsg          = ''
  22. local CurrentActionData         = {}
  23. local IsHandcuffed              = false
  24. local IsDragged                 = false
  25. local CopPed                    = 0
  26.  
  27. ESX                             = nil
  28. GUI.Time                        = 0
  29.  
  30. Citizen.CreateThread(function()
  31.   while ESX == nil do
  32.     TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  33.     Citizen.Wait(0)
  34.   end
  35. end)
  36.  
  37. function SetVehicleMaxMods(vehicle)
  38.  
  39.   local props = {
  40.     modEngine       = 2,
  41.     modBrakes       = 2,
  42.     modTransmission = 2,
  43.     modSuspension   = 3,
  44.     modTurbo        = true,
  45.   }
  46.  
  47.   ESX.Game.SetVehicleProperties(vehicle, props)
  48.  
  49. end
  50.  
  51. function OpenCloakroomMenu()
  52.  
  53.   local elements = {
  54.     { label = _U('citizen_wear'), value = 'citizen_wear' }
  55.   }
  56.  
  57.   if PlayerData.job.grade_name == 'recruit' then
  58.     table.insert(elements, {label = _U('police_wear'), value = 'cadet_wear'})
  59.   end
  60.  
  61.   if PlayerData.job.grade_name == 'officer' then
  62.     table.insert(elements, {label = _U('police_wear'), value = 'police_wear'})
  63.   end
  64.  
  65.   if PlayerData.job.grade_name == 'sergeant' then
  66.     table.insert(elements, {label = _U('police_wear'), value = 'sergeant_wear'})
  67.   end
  68.  
  69.   if PlayerData.job.grade_name == 'lieutenant' then
  70.     table.insert(elements, {label = _U('police_wear'), value = 'lieutenant_wear'})
  71.   end
  72.  
  73.   if PlayerData.job.grade_name == 'boss' then
  74.     table.insert(elements, {label = _U('police_wear'), value = 'commandant_wear'})
  75.   end
  76.  
  77.   if Config.EnableNonFreemodePeds then
  78.     table.insert(elements, {label = _U('sheriff_wear'), value = 'sheriff_wear_freemode'})
  79.     table.insert(elements, {label = _U('lieutenant_wear'), value = 'lieutenant_wear_freemode'})
  80.     table.insert(elements, {label = _U('commandant_wear'), value = 'commandant_wear_freemode'})
  81.   end
  82.  
  83.   table.insert(elements, {label = _U('bullet_wear'), value = 'bullet_wear'})
  84.   table.insert(elements, {label = _U('gilet_wear'), value = 'gilet_wear'})
  85.  
  86.   ESX.UI.Menu.CloseAll()
  87.  
  88.   ESX.UI.Menu.Open(
  89.     'default', GetCurrentResourceName(), 'cloakroom',
  90.     {
  91.       title    = _U('cloakroom'),
  92.       align    = 'top-left',
  93.       elements = elements,
  94.     },
  95.     function(data, menu)
  96.       menu.close()
  97.  
  98.       if data.current.value == 'citizen_wear' then
  99.         ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
  100.           local model = nil
  101.  
  102.           if skin.sex == 0 then
  103.             model = GetHashKey("mp_m_freemode_01")
  104.           else
  105.             model = GetHashKey("mp_f_freemode_01")
  106.           end
  107.  
  108.           RequestModel(model)
  109.           while not HasModelLoaded(model) do
  110.             RequestModel(model)
  111.             Citizen.Wait(1)
  112.           end
  113.  
  114.           SetPlayerModel(PlayerId(), model)
  115.           SetModelAsNoLongerNeeded(model)
  116.  
  117.           TriggerEvent('skinchanger:loadSkin', skin)
  118.           TriggerEvent('esx:restoreLoadout')
  119.           local playerPed = GetPlayerPed(-1)
  120.           SetPedArmour(playerPed, 0)
  121.           ClearPedBloodDamage(playerPed)
  122.           ResetPedVisibleDamage(playerPed)
  123.           ClearPedLastWeaponDamage(playerPed)
  124.         end)
  125.       end
  126.  
  127.       if data.current.value == 'cadet_wear' then
  128.         TriggerEvent('skinchanger:getSkin', function(skin)
  129.        
  130.             if skin.sex == 0 then
  131.  
  132.                 local clothesSkin = {
  133.                     ['tshirt_1'] = 59, ['tshirt_2'] = 1,
  134.                     ['torso_1'] = 55, ['torso_2'] = 0,
  135.                     ['decals_1'] = 0, ['decals_2'] = 0,
  136.                     ['arms'] = 41,
  137.                     ['pants_1'] = 25, ['pants_2'] = 0,
  138.                     ['shoes_1'] = 25, ['shoes_2'] = 0,
  139.                     ['helmet_1'] = 46, ['helmet_2'] = 0,
  140.                     ['chain_1'] = 0, ['chain_2'] = 0,
  141.                     ['ears_1'] = 2, ['ears_2'] = 0
  142.                 }
  143.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  144.  
  145.             else
  146.  
  147.                 local clothesSkin = {
  148.                     ['tshirt_1'] = 36, ['tshirt_2'] = 1,
  149.                     ['torso_1'] = 48, ['torso_2'] = 0,
  150.                     ['decals_1'] = 0, ['decals_2'] = 0,
  151.                     ['arms'] = 44,
  152.                     ['pants_1'] = 34, ['pants_2'] = 0,
  153.                     ['shoes_1'] = 27, ['shoes_2'] = 0,
  154.                     ['helmet_1'] = 45, ['helmet_2'] = 0,
  155.                     ['chain_1'] = 0, ['chain_2'] = 0,
  156.                     ['ears_1'] = 2, ['ears_2'] = 0
  157.                 }
  158.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  159.  
  160.             end
  161.  
  162.             local playerPed = GetPlayerPed(-1)
  163.             SetPedArmour(playerPed, 0)
  164.             ClearPedBloodDamage(playerPed)
  165.             ResetPedVisibleDamage(playerPed)
  166.             ClearPedLastWeaponDamage(playerPed)
  167.            
  168.         end)
  169.       end
  170.  
  171.       if data.current.value == 'police_wear' then
  172.         TriggerEvent('skinchanger:getSkin', function(skin)
  173.        
  174.             if skin.sex == 0 then
  175.  
  176.                 local clothesSkin = {
  177.                     ['tshirt_1'] = 58, ['tshirt_2'] = 0,
  178.                     ['torso_1'] = 55, ['torso_2'] = 0,
  179.                     ['decals_1'] = 0, ['decals_2'] = 0,
  180.                     ['arms'] = 41,
  181.                     ['pants_1'] = 25, ['pants_2'] = 0,
  182.                     ['shoes_1'] = 25, ['shoes_2'] = 0,
  183.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  184.                     ['chain_1'] = 0, ['chain_2'] = 0,
  185.                     ['ears_1'] = 2, ['ears_2'] = 0
  186.                 }
  187.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  188.  
  189.             else
  190.  
  191.                 local clothesSkin = {
  192.                     ['tshirt_1'] = 35, ['tshirt_2'] = 0,
  193.                     ['torso_1'] = 48, ['torso_2'] = 0,
  194.                     ['decals_1'] = 0, ['decals_2'] = 0,
  195.                     ['arms'] = 44,
  196.                     ['pants_1'] = 34, ['pants_2'] = 0,
  197.                     ['shoes_1'] = 27, ['shoes_2'] = 0,
  198.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  199.                     ['chain_1'] = 0, ['chain_2'] = 0,
  200.                     ['ears_1'] = 2, ['ears_2'] = 0
  201.                 }
  202.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  203.  
  204.             end
  205.  
  206.             local playerPed = GetPlayerPed(-1)
  207.             SetPedArmour(playerPed, 0)
  208.             ClearPedBloodDamage(playerPed)
  209.             ResetPedVisibleDamage(playerPed)
  210.             ClearPedLastWeaponDamage(playerPed)
  211.            
  212.         end)
  213.       end
  214.  
  215.       if data.current.value == 'sergeant_wear' then
  216.         TriggerEvent('skinchanger:getSkin', function(skin)
  217.        
  218.             if skin.sex == 0 then
  219.  
  220.                 local clothesSkin = {
  221.                     ['tshirt_1'] = 58, ['tshirt_2'] = 0,
  222.                     ['torso_1'] = 55, ['torso_2'] = 0,
  223.                     ['decals_1'] = 8, ['decals_2'] = 1,
  224.                     ['arms'] = 41,
  225.                     ['pants_1'] = 25, ['pants_2'] = 0,
  226.                     ['shoes_1'] = 25, ['shoes_2'] = 0,
  227.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  228.                     ['chain_1'] = 0, ['chain_2'] = 0,
  229.                     ['ears_1'] = 2, ['ears_2'] = 0
  230.                 }
  231.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  232.  
  233.             else
  234.  
  235.                 local clothesSkin = {
  236.                     ['tshirt_1'] = 35, ['tshirt_2'] = 0,
  237.                     ['torso_1'] = 48, ['torso_2'] = 0,
  238.                     ['decals_1'] = 7, ['decals_2'] = 1,
  239.                     ['arms'] = 44,
  240.                     ['pants_1'] = 34, ['pants_2'] = 0,
  241.                     ['shoes_1'] = 27, ['shoes_2'] = 0,
  242.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  243.                     ['chain_1'] = 0, ['chain_2'] = 0,
  244.                     ['ears_1'] = 2, ['ears_2'] = 0
  245.                 }
  246.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  247.  
  248.             end
  249.  
  250.             local playerPed = GetPlayerPed(-1)
  251.             SetPedArmour(playerPed, 0)
  252.             ClearPedBloodDamage(playerPed)
  253.             ResetPedVisibleDamage(playerPed)
  254.             ClearPedLastWeaponDamage(playerPed)
  255.            
  256.         end)
  257.       end
  258.  
  259.       if data.current.value == 'lieutenant_wear' then
  260.         TriggerEvent('skinchanger:getSkin', function(skin)
  261.        
  262.             if skin.sex == 0 then
  263.  
  264.                 local clothesSkin = {
  265.                     ['tshirt_1'] = 58, ['tshirt_2'] = 0,
  266.                     ['torso_1'] = 55, ['torso_2'] = 0,
  267.                     ['decals_1'] = 8, ['decals_2'] = 2,
  268.                     ['arms'] = 41,
  269.                     ['pants_1'] = 25, ['pants_2'] = 0,
  270.                     ['shoes_1'] = 25, ['shoes_2'] = 0,
  271.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  272.                     ['chain_1'] = 0, ['chain_2'] = 0,
  273.                     ['ears_1'] = 2, ['ears_2'] = 0
  274.                 }
  275.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  276.  
  277.             else
  278.  
  279.                 local clothesSkin = {
  280.                     ['tshirt_1'] = 35, ['tshirt_2'] = 0,
  281.                     ['torso_1'] = 48, ['torso_2'] = 0,
  282.                     ['decals_1'] = 7, ['decals_2'] = 2,
  283.                     ['arms'] = 44,
  284.                     ['pants_1'] = 34, ['pants_2'] = 0,
  285.                     ['shoes_1'] = 27, ['shoes_2'] = 0,
  286.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  287.                     ['chain_1'] = 0, ['chain_2'] = 0,
  288.                     ['ears_1'] = 2, ['ears_2'] = 0
  289.                 }
  290.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  291.  
  292.             end
  293.  
  294.             local playerPed = GetPlayerPed(-1)
  295.             SetPedArmour(playerPed, 0)
  296.             ClearPedBloodDamage(playerPed)
  297.             ResetPedVisibleDamage(playerPed)
  298.             ClearPedLastWeaponDamage(playerPed)
  299.            
  300.         end)
  301.       end
  302.  
  303.       if data.current.value == 'commandant_wear' then
  304.         TriggerEvent('skinchanger:getSkin', function(skin)
  305.        
  306.             if skin.sex == 0 then
  307.  
  308.                 local clothesSkin = {
  309.                     ['tshirt_1'] = 58, ['tshirt_2'] = 0,
  310.                     ['torso_1'] = 55, ['torso_2'] = 0,
  311.                     ['decals_1'] = 8, ['decals_2'] = 3,
  312.                     ['arms'] = 41,
  313.                     ['pants_1'] = 25, ['pants_2'] = 0,
  314.                     ['shoes_1'] = 25, ['shoes_2'] = 0,
  315.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  316.                     ['chain_1'] = 0, ['chain_2'] = 0,
  317.                     ['ears_1'] = 2, ['ears_2'] = 0
  318.                 }
  319.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  320.  
  321.             else
  322.  
  323.                 local clothesSkin = {
  324.                     ['tshirt_1'] = 35, ['tshirt_2'] = 0,
  325.                     ['torso_1'] = 48, ['torso_2'] = 0,
  326.                     ['decals_1'] = 7, ['decals_2'] = 3,
  327.                     ['arms'] = 44,
  328.                     ['pants_1'] = 34, ['pants_2'] = 0,
  329.                     ['shoes_1'] = 27, ['shoes_2'] = 0,
  330.                     ['helmet_1'] = -1, ['helmet_2'] = 0,
  331.                     ['chain_1'] = 0, ['chain_2'] = 0,
  332.                     ['ears_1'] = 2, ['ears_2'] = 0
  333.                 }
  334.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  335.  
  336.             end
  337.  
  338.             local playerPed = GetPlayerPed(-1)
  339.             SetPedArmour(playerPed, 0)
  340.             ClearPedBloodDamage(playerPed)
  341.             ResetPedVisibleDamage(playerPed)
  342.             ClearPedLastWeaponDamage(playerPed)
  343.            
  344.         end)
  345.       end
  346.  
  347.       if data.current.value == 'bullet_wear' then
  348.         TriggerEvent('skinchanger:getSkin', function(skin)
  349.        
  350.             if skin.sex == 0 then
  351.  
  352.                 local clothesSkin = {
  353.                     ['bproof_1'] = 11, ['bproof_2'] = 1
  354.                 }
  355.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  356.  
  357.             else
  358.  
  359.                 local clothesSkin = {
  360.                     ['bproof_1'] = 13, ['bproof_2'] = 1
  361.                 }
  362.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  363.  
  364.             end
  365.  
  366.             local playerPed = GetPlayerPed(-1)
  367.             SetPedArmour(playerPed, 100)
  368.             ClearPedBloodDamage(playerPed)
  369.             ResetPedVisibleDamage(playerPed)
  370.             ClearPedLastWeaponDamage(playerPed)
  371.            
  372.         end)
  373.       end
  374.  
  375.       if data.current.value == 'gilet_wear' then
  376.         TriggerEvent('skinchanger:getSkin', function(skin)
  377.        
  378.             if skin.sex == 0 then
  379.  
  380.                 local clothesSkin = {
  381.                     ['tshirt_1'] = 59, ['tshirt_2'] = 1
  382.                 }
  383.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  384.  
  385.             else
  386.  
  387.                 local clothesSkin = {
  388.                     ['tshirt_1'] = 36, ['tshirt_2'] = 1
  389.                 }
  390.                 TriggerEvent('skinchanger:loadClothes', skin, clothesSkin)
  391.  
  392.             end
  393.  
  394.             local playerPed = GetPlayerPed(-1)
  395.             SetPedArmour(playerPed, 0)
  396.             ClearPedBloodDamage(playerPed)
  397.             ResetPedVisibleDamage(playerPed)
  398.             ClearPedLastWeaponDamage(playerPed)
  399.            
  400.         end)
  401.       end
  402.  
  403.       if data.current.value == 'sheriff_wear_freemode' then
  404.         ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
  405.  
  406.         if skin.sex == 0 then
  407.  
  408.           local model = GetHashKey("s_m_y_sheriff_01")
  409.  
  410.           RequestModel(model)
  411.           while not HasModelLoaded(model) do
  412.             RequestModel(model)
  413.             Citizen.Wait(0)
  414.           end
  415.  
  416.           SetPlayerModel(PlayerId(), model)
  417.           SetModelAsNoLongerNeeded(model)
  418.       else
  419.           local model = GetHashKey("s_f_y_sheriff_01")
  420.  
  421.           RequestModel(model)
  422.           while not HasModelLoaded(model) do
  423.             RequestModel(model)
  424.             Citizen.Wait(0)
  425.           end
  426.  
  427.           SetPlayerModel(PlayerId(), model)
  428.           SetModelAsNoLongerNeeded(model)
  429.           end
  430.  
  431.         end)
  432.       end
  433.  
  434.       if data.current.value == 'lieutenant_wear_freemode' then
  435.  
  436.         ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
  437.  
  438.         if skin.sex == 0 then
  439.           local model = GetHashKey("s_m_y_swat_01")
  440.  
  441.           RequestModel(model)
  442.           while not HasModelLoaded(model) do
  443.             RequestModel(model)
  444.             Citizen.Wait(0)
  445.           end
  446.  
  447.           SetPlayerModel(PlayerId(), model)
  448.           SetModelAsNoLongerNeeded(model)
  449.       else
  450.           local model = GetHashKey("s_m_y_swat_01")
  451.  
  452.           RequestModel(model)
  453.           while not HasModelLoaded(model) do
  454.             RequestModel(model)
  455.             Citizen.Wait(0)
  456.           end
  457.  
  458.           SetPlayerModel(PlayerId(), model)
  459.           SetModelAsNoLongerNeeded(model)
  460.           end
  461.  
  462.         end)
  463.       end
  464.  
  465.       if data.current.value == 'commandant_wear_freemode' then
  466.  
  467.         ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
  468.  
  469.         if skin.sex == 0 then
  470.           local model = GetHashKey("S_M_Y_BLACKOPS_01")
  471.  
  472.           RequestModel(model)
  473.           while not HasModelLoaded(model) do
  474.             RequestModel(model)
  475.             Citizen.Wait(0)
  476.           end
  477.  
  478.           SetPlayerModel(PlayerId(), model)
  479.           SetModelAsNoLongerNeeded(model)
  480.       else
  481.           local model = GetHashKey("S_M_Y_BLACKOPS_01")
  482.  
  483.           RequestModel(model)
  484.           while not HasModelLoaded(model) do
  485.             RequestModel(model)
  486.             Citizen.Wait(0)
  487.           end
  488.  
  489.           SetPlayerModel(PlayerId(), model)
  490.           SetModelAsNoLongerNeeded(model)
  491.           end
  492.  
  493.         end)
  494.       end
  495.  
  496.       CurrentAction     = 'menu_cloakroom'
  497.       CurrentActionMsg  = _U('open_cloackroom')
  498.       CurrentActionData = {}
  499.  
  500.     end,
  501.     function(data, menu)
  502.  
  503.       menu.close()
  504.  
  505.       CurrentAction     = 'menu_cloakroom'
  506.       CurrentActionMsg  = _U('open_cloackroom')
  507.       CurrentActionData = {}
  508.     end
  509.   )
  510.  
  511. end
  512.  
  513. function OpenArmoryMenu(station)
  514.  
  515.   if Config.EnableArmoryManagement then
  516.  
  517.     local elements = {
  518.       {label = _U('get_weapon'), value = 'get_weapon'},
  519.       {label = _U('put_weapon'), value = 'put_weapon'},
  520.       {label = 'Prendre Objet',  value = 'get_stock'},
  521.       {label = 'D─é┬ęposer objet',  value = 'put_stock'}
  522.     }
  523.  
  524.     if PlayerData.job.grade_name == 'boss' then
  525.       table.insert(elements, {label = _U('buy_weapons'), value = 'buy_weapons'})
  526.     end
  527.  
  528.     ESX.UI.Menu.CloseAll()
  529.  
  530.     ESX.UI.Menu.Open(
  531.       'default', GetCurrentResourceName(), 'armory',
  532.       {
  533.         title    = _U('armory'),
  534.         align    = 'top-left',
  535.         elements = elements,
  536.       },
  537.       function(data, menu)
  538.  
  539.         if data.current.value == 'get_weapon' then
  540.           OpenGetWeaponMenu()
  541.         end
  542.  
  543.         if data.current.value == 'put_weapon' then
  544.           OpenPutWeaponMenu()
  545.         end
  546.  
  547.         if data.current.value == 'buy_weapons' then
  548.           OpenBuyWeaponsMenu(station)
  549.         end
  550.  
  551.         if data.current.value == 'put_stock' then
  552.               OpenPutStocksMenu()
  553.             end
  554.  
  555.             if data.current.value == 'get_stock' then
  556.               OpenGetStocksMenu()
  557.             end
  558.  
  559.       end,
  560.       function(data, menu)
  561.  
  562.         menu.close()
  563.  
  564.         CurrentAction     = 'menu_armory'
  565.         CurrentActionMsg  = _U('open_armory')
  566.         CurrentActionData = {station = station}
  567.       end
  568.     )
  569.  
  570.   else
  571.  
  572.     local elements = {}
  573.  
  574.     for i=1, #Config.PoliceStations[station].AuthorizedWeapons, 1 do
  575.       local weapon = Config.PoliceStations[station].AuthorizedWeapons[i]
  576.       table.insert(elements, {label = ESX.GetWeaponLabel(weapon.name), value = weapon.name})
  577.     end
  578.  
  579.     ESX.UI.Menu.CloseAll()
  580.  
  581.     ESX.UI.Menu.Open(
  582.       'default', GetCurrentResourceName(), 'armory',
  583.       {
  584.         title    = _U('armory'),
  585.         align    = 'top-left',
  586.         elements = elements,
  587.       },
  588.       function(data, menu)
  589.         local weapon = data.current.value
  590.         TriggerServerEvent('esx_policejob:giveWeapon', weapon,  1000)
  591.       end,
  592.       function(data, menu)
  593.  
  594.         menu.close()
  595.  
  596.         CurrentAction     = 'menu_armory'
  597.         CurrentActionMsg  = _U('open_armory')
  598.         CurrentActionData = {station = station}
  599.  
  600.       end
  601.     )
  602.  
  603.   end
  604.  
  605. end
  606.  
  607. function OpenVehicleSpawnerMenu(station, partNum)
  608.  
  609.   local vehicles = Config.PoliceStations[station].Vehicles
  610.  
  611.   ESX.UI.Menu.CloseAll()
  612.  
  613.   if Config.EnableSocietyOwnedVehicles then
  614.  
  615.     local elements = {}
  616.  
  617.     ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(garageVehicles)
  618.  
  619.       for i=1, #garageVehicles, 1 do
  620.         table.insert(elements, {label = GetDisplayNameFromVehicleModel(garageVehicles[i].model) .. ' [' .. garageVehicles[i].plate .. ']', value = garageVehicles[i]})
  621.       end
  622.  
  623.       ESX.UI.Menu.Open(
  624.         'default', GetCurrentResourceName(), 'vehicle_spawner',
  625.         {
  626.           title    = _U('vehicle_menu'),
  627.           align    = 'top-left',
  628.           elements = elements,
  629.         },
  630.         function(data, menu)
  631.  
  632.           menu.close()
  633.  
  634.           local vehicleProps = data.current.value
  635.  
  636.           ESX.Game.SpawnVehicle(vehicleProps.model, vehicles[partNum].SpawnPoint, 270.0, function(vehicle)
  637.             ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
  638.             local playerPed = GetPlayerPed(-1)
  639.             TaskWarpPedIntoVehicle(playerPed,  vehicle,  -1)
  640.           end)
  641.  
  642.           TriggerServerEvent('esx_society:removeVehicleFromGarage', 'police', vehicleProps)
  643.  
  644.         end,
  645.         function(data, menu)
  646.  
  647.           menu.close()
  648.  
  649.           CurrentAction     = 'menu_vehicle_spawner'
  650.           CurrentActionMsg  = _U('vehicle_spawner')
  651.           CurrentActionData = {station = station, partNum = partNum}
  652.  
  653.         end
  654.       )
  655.  
  656.     end, 'police')
  657.  
  658.   else
  659.  
  660.     local elements = {}
  661.  
  662.     table.insert(elements, { label = 'Rower', value = 'fixter' })
  663.  
  664.     if PlayerData.job.grade_name == 'recruit' then
  665.           table.insert(elements, { label = 'Radiowoz 2', value = 'police2'})
  666.       table.insert(elements, { label = 'Radiowoz 3', value = 'police3'})
  667.       table.insert(elements, { label = 'Radiowoz 4', value = 'police4'})
  668.       table.insert(elements, { label = 'Doge Charger', value = 'pd2'})
  669.       table.insert(elements, { label = 'Ford expedition', value = 'pd4'})
  670.       table.insert(elements, { label = 'Chevrolet exproler', value = 'pd5'})
  671.       table.insert(elements, { label = 'Chevrolet silverado', value = 'pd6'})
  672.       table.insert(elements, { label = 'Crown victoria', value = 'pd8'})
  673.       table.insert(elements, { label = 'Chevrolet impala', value = 'pd9'})
  674.       table.insert(elements, { label = 'Ford Interceptor', value = 'pd10'})
  675.       table.insert(elements, { label = 'Motor', value = 'policeb'})
  676.       table.insert(elements, { label = 'Woz transportowy', value = 'pbus'})
  677.       table.insert(elements, { label = 'Police Insurgent', value = 'policeinsurgent'})
  678.       table.insert(elements, { label = 'Riot', value = 'riot'})
  679.       table.insert(elements, { label = 'Riot2', value = 'riot2'})
  680.       table.insert(elements, { label = 'Nieoznakowany radiowoz', value = 'fbi'})
  681.       table.insert(elements, { label = 'Nieoznakowany Suv', value = 'fbi2'})
  682.       table.insert(elements, { label = 'Lamborghini Avendador', value = 'polaventa'})
  683.       table.insert(elements, { label = 'Porsche 718', value = 'pol718'})
  684.       table.insert(elements, { label = 'hwaycar 1', value = 'hwaycar'})
  685.       table.insert(elements, { label = 'Mustang PD', value = '2015polstang'})
  686.       table.insert(elements, { label = 'hwaycar 3', value = 'hwaycar3'})
  687.       table.insert(elements, { label = 'hwaycar 4', value = 'hwaycar4'})
  688.       table.insert(elements, { label = 'hwaycar 5', value = 'hwaycar5'})
  689.       table.insert(elements, { label = 'hwaycar 6', value = 'hwaycar6'})
  690.       table.insert(elements, { label = 'hwaycar 7', value = 'hwaycar7'})
  691.       table.insert(elements, { label = 'hwaycar 8', value = 'hwaycar8'})
  692.       table.insert(elements, { label = 'hwaycar 9', value = 'hwaycar9'})
  693.       table.insert(elements, { label = 'PolUnmarked', value = 'fbi'})
  694.       table.insert(elements, { label = 'hwaycar 11', value = 'hwaycar11'})
  695.       table.insert(elements, { label = 'hwaycar 12', value = 'hwaycar12'})
  696.       table.insert(elements, { label = 'hwaycar 13', value = 'hwaycar13'})
  697.       table.insert(elements, { label = 'hwaycar 14', value = 'hwaycar14'})
  698.       table.insert(elements, { label = 'hwaycar 15', value = 'hwaycar15'})
  699.       table.insert(elements, { label = 'hwaycar 16', value = 'hwaycar16'})
  700.       table.insert(elements, { label = 'hwaycar 17', value = 'hwaycar17'})
  701.       table.insert(elements, { label = 'hwaycar 18', value = 'hwaycar18'})
  702.       table.insert(elements, { label = 'hwaycar 19', value = 'hwaycar19'})
  703.       table.insert(elements, { label = 'hwaycar 20', value = 'hwaycar20'})
  704.       table.insert(elements, { label = 'hwaycar 21', value = 'hwaycar21'})
  705.       table.insert(elements, { label = 'hwaycar 22', value = 'hwaycar22'})
  706.       table.insert(elements, { label = 'hwaycar 23', value = 'hwaycar23'})
  707.       table.insert(elements, { label = 'Unmarked 1', value = 'unmarked1'})
  708.       table.insert(elements, { label = 'Unmarked 2', value = 'unmarked2'})
  709.       table.insert(elements, { label = 'Unmarked 3', value = 'unmarked3'})
  710.       table.insert(elements, { label = 'Unmarked 4', value = 'unmarked4'})
  711.       table.insert(elements, { label = 'Unmarked 5', value = 'unmarked5'})
  712.       table.insert(elements, { label = 'Unmarked 6', value = 'unmarked6'})
  713.       table.insert(elements, { label = 'Unmarked 7', value = 'unmarked7'})
  714.       table.insert(elements, { label = 'Unmarked 8', value = 'unmarked8'})
  715.       table.insert(elements, { label = 'Unmarked 9', value = 'unmarked9'})
  716.     end
  717.        
  718.     if PlayerData.job.grade_name == 'officer' then
  719.           table.insert(elements, { label = 'Radiowoz 2', value = 'police2'})
  720.       table.insert(elements, { label = 'Radiowoz 3', value = 'police3'})
  721.       table.insert(elements, { label = 'Radiowoz 4', value = 'police4'})
  722.       table.insert(elements, { label = 'Doge Charger', value = 'pd2'})
  723.       table.insert(elements, { label = 'Ford expedition', value = 'pd4'})
  724.       table.insert(elements, { label = 'Chevrolet exproler', value = 'pd5'})
  725.       table.insert(elements, { label = 'Chevrolet silverado', value = 'pd6'})
  726.       table.insert(elements, { label = 'Crown victoria', value = 'pd8'})
  727.       table.insert(elements, { label = 'Chevrolet impala', value = 'pd9'})
  728.       table.insert(elements, { label = 'Ford Interceptor', value = 'pd10'})
  729.       table.insert(elements, { label = 'Motor', value = 'policeb'})
  730.       table.insert(elements, { label = 'Woz transportowy', value = 'pbus'})
  731.       table.insert(elements, { label = 'Police Insurgent', value = 'policeinsurgent'})
  732.       table.insert(elements, { label = 'Riot', value = 'riot'})
  733.       table.insert(elements, { label = 'Riot2', value = 'riot2'})
  734.       table.insert(elements, { label = 'Nieoznakowany radiowoz', value = 'fbi'})
  735.       table.insert(elements, { label = 'Nieoznakowany Suv', value = 'fbi2'})
  736.       table.insert(elements, { label = 'Lamborghini Avendador', value = 'polaventa'})
  737.       table.insert(elements, { label = 'Porsche 718', value = 'pol718'})
  738.       table.insert(elements, { label = 'hwaycar 1', value = 'hwaycar'})
  739.       table.insert(elements, { label = 'Mustang PD', value = '2015polstang'})
  740.       table.insert(elements, { label = 'hwaycar 3', value = 'hwaycar3'})
  741.       table.insert(elements, { label = 'hwaycar 4', value = 'hwaycar4'})
  742.       table.insert(elements, { label = 'hwaycar 5', value = 'hwaycar5'})
  743.       table.insert(elements, { label = 'hwaycar 6', value = 'hwaycar6'})
  744.       table.insert(elements, { label = 'hwaycar 7', value = 'hwaycar7'})
  745.       table.insert(elements, { label = 'hwaycar 8', value = 'hwaycar8'})
  746.       table.insert(elements, { label = 'hwaycar 9', value = 'hwaycar9'})
  747.       table.insert(elements, { label = 'PolUnmarked', value = 'fbi'})
  748.       table.insert(elements, { label = 'hwaycar 11', value = 'hwaycar11'})
  749.       table.insert(elements, { label = 'hwaycar 12', value = 'hwaycar12'})
  750.       table.insert(elements, { label = 'hwaycar 13', value = 'hwaycar13'})
  751.       table.insert(elements, { label = 'hwaycar 14', value = 'hwaycar14'})
  752.       table.insert(elements, { label = 'hwaycar 15', value = 'hwaycar15'})
  753.       table.insert(elements, { label = 'hwaycar 16', value = 'hwaycar16'})
  754.       table.insert(elements, { label = 'hwaycar 17', value = 'hwaycar17'})
  755.       table.insert(elements, { label = 'hwaycar 18', value = 'hwaycar18'})
  756.       table.insert(elements, { label = 'hwaycar 19', value = 'hwaycar19'})
  757.       table.insert(elements, { label = 'hwaycar 20', value = 'hwaycar20'})
  758.       table.insert(elements, { label = 'hwaycar 21', value = 'hwaycar21'})
  759.       table.insert(elements, { label = 'hwaycar 22', value = 'hwaycar22'})
  760.       table.insert(elements, { label = 'hwaycar 23', value = 'hwaycar23'})
  761.       table.insert(elements, { label = 'Unmarked 1', value = 'unmarked1'})
  762.       table.insert(elements, { label = 'Unmarked 2', value = 'unmarked2'})
  763.       table.insert(elements, { label = 'Unmarked 3', value = 'unmarked3'})
  764.       table.insert(elements, { label = 'Unmarked 4', value = 'unmarked4'})
  765.       table.insert(elements, { label = 'Unmarked 5', value = 'unmarked5'})
  766.       table.insert(elements, { label = 'Unmarked 6', value = 'unmarked6'})
  767.       table.insert(elements, { label = 'Unmarked 7', value = 'unmarked7'})
  768.       table.insert(elements, { label = 'Unmarked 8', value = 'unmarked8'})
  769.       table.insert(elements, { label = 'Unmarked 9', value = 'unmarked9'})
  770.     end
  771.  
  772.     if PlayerData.job.grade_name == 'sergeant' then
  773.           table.insert(elements, { label = 'Radiowoz 2', value = 'police2'})
  774.       table.insert(elements, { label = 'Radiowoz 3', value = 'police3'})
  775.       table.insert(elements, { label = 'Radiowoz 4', value = 'police4'})
  776.       table.insert(elements, { label = 'Doge Charger', value = 'pd2'})
  777.       table.insert(elements, { label = 'Ford expedition', value = 'pd4'})
  778.       table.insert(elements, { label = 'Chevrolet exproler', value = 'pd5'})
  779.       table.insert(elements, { label = 'Chevrolet silverado', value = 'pd6'})
  780.       table.insert(elements, { label = 'Crown victoria', value = 'pd8'})
  781.       table.insert(elements, { label = 'Chevrolet impala', value = 'pd9'})
  782.       table.insert(elements, { label = 'Ford Interceptor', value = 'pd10'})
  783.       table.insert(elements, { label = 'Motor', value = 'policeb'})
  784.       table.insert(elements, { label = 'Woz transportowy', value = 'pbus'})
  785.       table.insert(elements, { label = 'Police Insurgent', value = 'policeinsurgent'})
  786.       table.insert(elements, { label = 'Riot', value = 'riot'})
  787.       table.insert(elements, { label = 'Riot2', value = 'riot2'})
  788.       table.insert(elements, { label = 'Nieoznakowany radiowoz', value = 'fbi'})
  789.       table.insert(elements, { label = 'Nieoznakowany Suv', value = 'fbi2'})
  790.       table.insert(elements, { label = 'Lamborghini Avendador', value = 'polaventa'})
  791.       table.insert(elements, { label = 'Porsche 718', value = 'pol718'})
  792.       table.insert(elements, { label = 'hwaycar 1', value = 'hwaycar'})
  793.       table.insert(elements, { label = 'Mustang PD, value = '2015polstang'})
  794.       table.insert(elements, { label = 'hwaycar 3', value = 'hwaycar3'})
  795.       table.insert(elements, { label = 'hwaycar 4', value = 'hwaycar4'})
  796.       table.insert(elements, { label = 'hwaycar 5', value = 'hwaycar5'})
  797.       table.insert(elements, { label = 'hwaycar 6', value = 'hwaycar6'})
  798.       table.insert(elements, { label = 'hwaycar 7', value = 'hwaycar7'})
  799.       table.insert(elements, { label = 'hwaycar 8', value = 'hwaycar8'})
  800.       table.insert(elements, { label = 'hwaycar 9', value = 'hwaycar9'})
  801.       table.insert(elements, { label = 'PolUnmarked', value = 'fbi'})
  802.       table.insert(elements, { label = 'hwaycar 11', value = 'hwaycar11'})
  803.       table.insert(elements, { label = 'hwaycar 12', value = 'hwaycar12'})
  804.       table.insert(elements, { label = 'hwaycar 13', value = 'hwaycar13'})
  805.       table.insert(elements, { label = 'hwaycar 14', value = 'hwaycar14'})
  806.       table.insert(elements, { label = 'hwaycar 15', value = 'hwaycar15'})
  807.       table.insert(elements, { label = 'hwaycar 16', value = 'hwaycar16'})
  808.       table.insert(elements, { label = 'hwaycar 17', value = 'hwaycar17'})
  809.       table.insert(elements, { label = 'hwaycar 18', value = 'hwaycar18'})
  810.       table.insert(elements, { label = 'hwaycar 19', value = 'hwaycar19'})
  811.       table.insert(elements, { label = 'hwaycar 20', value = 'hwaycar20'})
  812.       table.insert(elements, { label = 'hwaycar 21', value = 'hwaycar21'})
  813.       table.insert(elements, { label = 'hwaycar 22', value = 'hwaycar22'})
  814.       table.insert(elements, { label = 'hwaycar 23', value = 'hwaycar23'})
  815.       table.insert(elements, { label = 'Unmarked 1', value = 'unmarked1'})
  816.       table.insert(elements, { label = 'Unmarked 2', value = 'unmarked2'})
  817.       table.insert(elements, { label = 'Unmarked 3', value = 'unmarked3'})
  818.       table.insert(elements, { label = 'Unmarked 4', value = 'unmarked4'})
  819.       table.insert(elements, { label = 'Unmarked 5', value = 'unmarked5'})
  820.       table.insert(elements, { label = 'Unmarked 6', value = 'unmarked6'})
  821.       table.insert(elements, { label = 'Unmarked 7', value = 'unmarked7'})
  822.       table.insert(elements, { label = 'Unmarked 8', value = 'unmarked8'})
  823.       table.insert(elements, { label = 'Unmarked 9', value = 'unmarked9'})
  824.     end
  825.  
  826.     if PlayerData.job.grade_name == 'lieutenant' then
  827.           table.insert(elements, { label = 'Radiowoz 2', value = 'police2'})
  828.       table.insert(elements, { label = 'Radiowoz 3', value = 'police3'})
  829.       table.insert(elements, { label = 'Radiowoz 4', value = 'police4'})
  830.       table.insert(elements, { label = 'Doge Charger', value = 'pd2'})
  831.       table.insert(elements, { label = 'Ford expedition', value = 'pd4'})
  832.       table.insert(elements, { label = 'Chevrolet exproler', value = 'pd5'})
  833.       table.insert(elements, { label = 'Chevrolet silverado', value = 'pd6'})
  834.       table.insert(elements, { label = 'Crown victoria', value = 'pd8'})
  835.       table.insert(elements, { label = 'Chevrolet impala', value = 'pd9'})
  836.       table.insert(elements, { label = 'Ford Interceptor', value = 'pd10'})
  837.       table.insert(elements, { label = 'Motor', value = 'policeb'})
  838.       table.insert(elements, { label = 'Woz transportowy', value = 'pbus'})
  839.       table.insert(elements, { label = 'Police Insurgent', value = 'policeinsurgent'})
  840.       table.insert(elements, { label = 'Riot', value = 'riot'})
  841.       table.insert(elements, { label = 'Riot2', value = 'riot2'})
  842.       table.insert(elements, { label = 'Nieoznakowany radiowoz', value = 'fbi'})
  843.       table.insert(elements, { label = 'Nieoznakowany Suv', value = 'fbi2'})
  844.       table.insert(elements, { label = 'Lamborghini Avendador', value = 'polaventa'})
  845.       table.insert(elements, { label = 'Porsche 718', value = 'pol718'})
  846.       table.insert(elements, { label = 'hwaycar 1', value = 'hwaycar'})
  847.       table.insert(elements, { label = 'Mustang PD', value = '2015polstang'})
  848.       table.insert(elements, { label = 'hwaycar 3', value = 'hwaycar3'})
  849.       table.insert(elements, { label = 'hwaycar 4', value = 'hwaycar4'})
  850.       table.insert(elements, { label = 'hwaycar 5', value = 'hwaycar5'})
  851.       table.insert(elements, { label = 'hwaycar 6', value = 'hwaycar6'})
  852.       table.insert(elements, { label = 'hwaycar 7', value = 'hwaycar7'})
  853.       table.insert(elements, { label = 'hwaycar 8', value = 'hwaycar8'})
  854.       table.insert(elements, { label = 'hwaycar 9', value = 'hwaycar9'})
  855.       table.insert(elements, { label = 'PolUnmarked', value = 'fbi'})
  856.       table.insert(elements, { label = 'hwaycar 11', value = 'hwaycar11'})
  857.       table.insert(elements, { label = 'hwaycar 12', value = 'hwaycar12'})
  858.       table.insert(elements, { label = 'hwaycar 13', value = 'hwaycar13'})
  859.       table.insert(elements, { label = 'hwaycar 14', value = 'hwaycar14'})
  860.       table.insert(elements, { label = 'hwaycar 15', value = 'hwaycar15'})
  861.       table.insert(elements, { label = 'hwaycar 16', value = 'hwaycar16'})
  862.       table.insert(elements, { label = 'hwaycar 17', value = 'hwaycar17'})
  863.       table.insert(elements, { label = 'hwaycar 18', value = 'hwaycar18'})
  864.       table.insert(elements, { label = 'hwaycar 19', value = 'hwaycar19'})
  865.       table.insert(elements, { label = 'hwaycar 20', value = 'hwaycar20'})
  866.       table.insert(elements, { label = 'hwaycar 21', value = 'hwaycar21'})
  867.       table.insert(elements, { label = 'hwaycar 22', value = 'hwaycar22'})
  868.       table.insert(elements, { label = 'hwaycar 23', value = 'hwaycar23'})
  869.       table.insert(elements, { label = 'Unmarked 1', value = 'unmarked1'})
  870.       table.insert(elements, { label = 'Unmarked 2', value = 'unmarked2'})
  871.       table.insert(elements, { label = 'Unmarked 3', value = 'unmarked3'})
  872.       table.insert(elements, { label = 'Unmarked 4', value = 'unmarked4'})
  873.       table.insert(elements, { label = 'Unmarked 5', value = 'unmarked5'})
  874.       table.insert(elements, { label = 'Unmarked 6', value = 'unmarked6'})
  875.       table.insert(elements, { label = 'Unmarked 7', value = 'unmarked7'})
  876.       table.insert(elements, { label = 'Unmarked 8', value = 'unmarked8'})
  877.       table.insert(elements, { label = 'Unmarked 9', value = 'unmarked9'})
  878.     end
  879.  
  880.     if PlayerData.job.grade_name == 'boss' then
  881.           table.insert(elements, { label = 'Radiowoz 2', value = 'police2'})
  882.       table.insert(elements, { label = 'Radiowoz 3', value = 'police3'})
  883.       table.insert(elements, { label = 'Radiowoz 4', value = 'police4'})
  884.       table.insert(elements, { label = 'Doge Charger', value = 'pd2'})
  885.       table.insert(elements, { label = 'Ford expedition', value = 'pd4'})
  886.       table.insert(elements, { label = 'Chevrolet exproler', value = 'pd5'})
  887.       table.insert(elements, { label = 'Chevrolet silverado', value = 'pd6'})
  888.       table.insert(elements, { label = 'Crown victoria', value = 'pd8'})
  889.       table.insert(elements, { label = 'Chevrolet impala', value = 'pd9'})
  890.       table.insert(elements, { label = 'Ford Interceptor', value = 'pd10'})
  891.       table.insert(elements, { label = 'Motor', value = 'policeb'})
  892.       table.insert(elements, { label = 'Woz transportowy', value = 'pbus'})
  893.       table.insert(elements, { label = 'Police Insurgent', value = 'policeinsurgent'})
  894.       table.insert(elements, { label = 'Riot', value = 'riot'})
  895.       table.insert(elements, { label = 'Riot2', value = 'riot2'})
  896.       table.insert(elements, { label = 'Nieoznakowany radiowoz', value = 'fbi'})
  897.       table.insert(elements, { label = 'Nieoznakowany Suv', value = 'fbi2'})
  898.       table.insert(elements, { label = 'Lamborghini Avendador', value = 'polaventa'})
  899.       table.insert(elements, { label = 'Porsche 718', value = 'pol718'})
  900.       table.insert(elements, { label = 'hwaycar 1', value = 'hwaycar'})
  901.       table.insert(elements, { label = 'Mustang PD', value = '2015polstang'})
  902.       table.insert(elements, { label = 'hwaycar 3', value = 'hwaycar3'})
  903.       table.insert(elements, { label = 'hwaycar 4', value = 'hwaycar4'})
  904.       table.insert(elements, { label = 'hwaycar 5', value = 'hwaycar5'})
  905.       table.insert(elements, { label = 'hwaycar 6', value = 'hwaycar6'})
  906.       table.insert(elements, { label = 'hwaycar 7', value = 'hwaycar7'})
  907.       table.insert(elements, { label = 'hwaycar 8', value = 'hwaycar8'})
  908.       table.insert(elements, { label = 'hwaycar 9', value = 'hwaycar9'})
  909.       table.insert(elements, { label = 'PolUnmarked', value = 'fbi'})
  910.       table.insert(elements, { label = 'hwaycar 11', value = 'hwaycar11'})
  911.       table.insert(elements, { label = 'hwaycar 12', value = 'hwaycar12'})
  912.       table.insert(elements, { label = 'hwaycar 13', value = 'hwaycar13'})
  913.       table.insert(elements, { label = 'hwaycar 14', value = 'hwaycar14'})
  914.       table.insert(elements, { label = 'hwaycar 15', value = 'hwaycar15'})
  915.       table.insert(elements, { label = 'hwaycar 16', value = 'hwaycar16'})
  916.       table.insert(elements, { label = 'hwaycar 17', value = 'hwaycar17'})
  917.       table.insert(elements, { label = 'hwaycar 18', value = 'hwaycar18'})
  918.       table.insert(elements, { label = 'hwaycar 19', value = 'hwaycar19'})
  919.       table.insert(elements, { label = 'hwaycar 20', value = 'hwaycar20'})
  920.       table.insert(elements, { label = 'hwaycar 21', value = 'hwaycar21'})
  921.       table.insert(elements, { label = 'hwaycar 22', value = 'hwaycar22'})
  922.       table.insert(elements, { label = 'hwaycar 23', value = 'hwaycar23'})
  923.       table.insert(elements, { label = 'Unmarked 1', value = 'unmarked1'})
  924.       table.insert(elements, { label = 'Unmarked 2', value = 'unmarked2'})
  925.       table.insert(elements, { label = 'Unmarked 3', value = 'unmarked3'})
  926.       table.insert(elements, { label = 'Unmarked 4', value = 'unmarked4'})
  927.       table.insert(elements, { label = 'Unmarked 5', value = 'unmarked5'})
  928.       table.insert(elements, { label = 'Unmarked 6', value = 'unmarked6'})
  929.       table.insert(elements, { label = 'Unmarked 7', value = 'unmarked7'})
  930.       table.insert(elements, { label = 'Unmarked 8', value = 'unmarked8'})
  931.       table.insert(elements, { label = 'Unmarked 9', value = 'unmarked9'})
  932.     end
  933.  
  934.     ESX.UI.Menu.Open(
  935.       'default', GetCurrentResourceName(), 'vehicle_spawner',
  936.       {
  937.         title    = _U('vehicle_menu'),
  938.         align    = 'top-left',
  939.         elements = elements,
  940.       },
  941.       function(data, menu)
  942.  
  943.         menu.close()
  944.  
  945.         local model = data.current.value
  946.  
  947.         local vehicle = GetClosestVehicle(vehicles[partNum].SpawnPoint.x,  vehicles[partNum].SpawnPoint.y,  vehicles[partNum].SpawnPoint.z,  3.0,  0,  71)
  948.  
  949.         if not DoesEntityExist(vehicle) then
  950.  
  951.           local playerPed = GetPlayerPed(-1)
  952.  
  953.           if Config.MaxInService == -1 then
  954.  
  955.             ESX.Game.SpawnVehicle(model, {
  956.               x = vehicles[partNum].SpawnPoint.x,
  957.               y = vehicles[partNum].SpawnPoint.y,
  958.               z = vehicles[partNum].SpawnPoint.z
  959.             }, vehicles[partNum].Heading, function(vehicle)
  960.               TaskWarpPedIntoVehicle(playerPed,  vehicle,  -1)
  961.               SetVehicleMaxMods(vehicle)
  962.             end)
  963.  
  964.           else
  965.  
  966.             ESX.TriggerServerCallback('esx_service:enableService', function(canTakeService, maxInService, inServiceCount)
  967.  
  968.               if canTakeService then
  969.  
  970.                 ESX.Game.SpawnVehicle(model, {
  971.                   x = vehicles[partNum].SpawnPoint.x,
  972.                   y = vehicles[partNum].SpawnPoint.y,
  973.                   z = vehicles[partNum].SpawnPoint.z
  974.                 }, vehicles[partNum].Heading, function(vehicle)
  975.                   TaskWarpPedIntoVehicle(playerPed,  vehicle,  -1)
  976.                   SetVehicleMaxMods(vehicle)
  977.                 end)
  978.  
  979.               else
  980.                 ESX.ShowNotification(_U('service_max') .. inServiceCount .. '/' .. maxInService)
  981.               end
  982.  
  983.             end, 'police')
  984.  
  985.           end
  986.  
  987.         else
  988.           ESX.ShowNotification(_U('vehicle_out'))
  989.         end
  990.  
  991.       end,
  992.       function(data, menu)
  993.  
  994.         menu.close()
  995.  
  996.         CurrentAction     = 'menu_vehicle_spawner'
  997.         CurrentActionMsg  = _U('vehicle_spawner')
  998.         CurrentActionData = {station = station, partNum = partNum}
  999.  
  1000.       end
  1001.     )
  1002.  
  1003.   end
  1004.  
  1005. end
  1006.  
  1007. function OpenPoliceActionsMenu()
  1008.  
  1009.   ESX.UI.Menu.CloseAll()
  1010.  
  1011.   ESX.UI.Menu.Open(
  1012.     'default', GetCurrentResourceName(), 'police_actions',
  1013.     {
  1014.       title    = 'Police',
  1015.       align    = 'top-left',
  1016.       elements = {
  1017.         {label = _U('citizen_interaction'), value = 'citizen_interaction'},
  1018.         {label = _U('vehicle_interaction'), value = 'vehicle_interaction'},
  1019.         {label = _U('object_spawner'),      value = 'object_spawner'},
  1020.       },
  1021.     },
  1022.     function(data, menu)
  1023.  
  1024.       if data.current.value == 'citizen_interaction' then
  1025.  
  1026.         ESX.UI.Menu.Open(
  1027.           'default', GetCurrentResourceName(), 'citizen_interaction',
  1028.           {
  1029.             title    = _U('citizen_interaction'),
  1030.             align    = 'top-left',
  1031.             elements = {
  1032.               {label = _U('id_card'),       value = 'identity_card'},
  1033.               {label = _U('search'),        value = 'body_search'},
  1034.               {label = _U('handcuff'),    value = 'handcuff'},
  1035.               {label = _U('drag'),      value = 'drag'},
  1036.               {label = _U('put_in_vehicle'),  value = 'put_in_vehicle'},
  1037.               {label = _U('out_the_vehicle'), value = 'out_the_vehicle'},
  1038.               {label = _U('fine'),            value = 'fine'}
  1039.             },
  1040.           },
  1041.           function(data2, menu2)
  1042.  
  1043.             local player, distance = ESX.Game.GetClosestPlayer()
  1044.  
  1045.             if distance ~= -1 and distance <= 3.0 then
  1046.  
  1047.               if data2.current.value == 'identity_card' then
  1048.                 OpenIdentityCardMenu(player)
  1049.               end
  1050.  
  1051.               if data2.current.value == 'body_search' then
  1052.                 OpenBodySearchMenu(player)
  1053.               end
  1054.  
  1055.               if data2.current.value == 'handcuff' then
  1056.                 TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(player))
  1057.               end
  1058.  
  1059.               if data2.current.value == 'drag' then
  1060.                 TriggerServerEvent('esx_policejob:drag', GetPlayerServerId(player))
  1061.               end
  1062.  
  1063.               if data2.current.value == 'put_in_vehicle' then
  1064.                 TriggerServerEvent('esx_policejob:putInVehicle', GetPlayerServerId(player))
  1065.               end
  1066.  
  1067.               if data2.current.value == 'out_the_vehicle' then
  1068.                   TriggerServerEvent('esx_policejob:OutVehicle', GetPlayerServerId(player))
  1069.               end
  1070.  
  1071.               if data2.current.value == 'fine' then
  1072.                 OpenFineMenu(player)
  1073.               end
  1074.  
  1075.             else
  1076.               ESX.ShowNotification(_U('no_players_nearby'))
  1077.             end
  1078.  
  1079.           end,
  1080.           function(data2, menu2)
  1081.             menu2.close()
  1082.           end
  1083.         )
  1084.  
  1085.       end
  1086.  
  1087.       if data.current.value == 'vehicle_interaction' then
  1088.  
  1089.         ESX.UI.Menu.Open(
  1090.           'default', GetCurrentResourceName(), 'vehicle_interaction',
  1091.           {
  1092.             title    = _U('vehicle_interaction'),
  1093.             align    = 'top-left',
  1094.             elements = {
  1095.               {label = _U('vehicle_info'), value = 'vehicle_infos'},
  1096.               {label = _U('pick_lock'),    value = 'hijack_vehicle'},
  1097.             },
  1098.           },
  1099.           function(data2, menu2)
  1100.  
  1101.             local playerPed = GetPlayerPed(-1)
  1102.             local coords    = GetEntityCoords(playerPed)
  1103.             local vehicle   = GetClosestVehicle(coords.x,  coords.y,  coords.z,  3.0,  0,  71)
  1104.  
  1105.             if DoesEntityExist(vehicle) then
  1106.  
  1107.               local vehicleData = ESX.Game.GetVehicleProperties(vehicle)
  1108.  
  1109.               if data2.current.value == 'vehicle_infos' then
  1110.                 OpenVehicleInfosMenu(vehicleData)
  1111.               end
  1112.  
  1113.               if data2.current.value == 'hijack_vehicle' then
  1114.  
  1115.                 local playerPed = GetPlayerPed(-1)
  1116.                 local coords    = GetEntityCoords(playerPed)
  1117.  
  1118.                 if IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 3.0) then
  1119.  
  1120.                   local vehicle = GetClosestVehicle(coords.x,  coords.y,  coords.z,  3.0,  0,  71)
  1121.  
  1122.                   if DoesEntityExist(vehicle) then
  1123.  
  1124.                     Citizen.CreateThread(function()
  1125.  
  1126.                       TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_WELDING", 0, true)
  1127.  
  1128.                       Wait(20000)
  1129.  
  1130.                       ClearPedTasksImmediately(playerPed)
  1131.  
  1132.                       SetVehicleDoorsLocked(vehicle, 1)
  1133.                       SetVehicleDoorsLockedForAllPlayers(vehicle, false)
  1134.  
  1135.                       TriggerEvent('esx:showNotification', _U('vehicle_unlocked'))
  1136.  
  1137.                     end)
  1138.  
  1139.                   end
  1140.  
  1141.                 end
  1142.  
  1143.               end
  1144.  
  1145.             else
  1146.               ESX.ShowNotification(_U('no_vehicles_nearby'))
  1147.             end
  1148.  
  1149.           end,
  1150.           function(data2, menu2)
  1151.             menu2.close()
  1152.           end
  1153.         )
  1154.  
  1155.       end
  1156.  
  1157.       if data.current.value == 'object_spawner' then
  1158.  
  1159.         ESX.UI.Menu.Open(
  1160.           'default', GetCurrentResourceName(), 'citizen_interaction',
  1161.           {
  1162.             title    = _U('traffic_interaction'),
  1163.             align    = 'top-left',
  1164.             elements = {
  1165.               {label = _U('cone'),     value = 'prop_roadcone02a'},
  1166.               {label = _U('barrier'), value = 'prop_barrier_work06a'},
  1167.               {label = _U('spikestrips'),    value = 'p_ld_stinger_s'},
  1168.               {label = _U('box'),   value = 'prop_boxpile_07d'},
  1169.               {label = _U('cash'),   value = 'hei_prop_cash_crate_half_full'}
  1170.             },
  1171.           },
  1172.           function(data2, menu2)
  1173.  
  1174.  
  1175.             local model     = data2.current.value
  1176.             local playerPed = GetPlayerPed(-1)
  1177.             local coords    = GetEntityCoords(playerPed)
  1178.             local forward   = GetEntityForwardVector(playerPed)
  1179.             local x, y, z   = table.unpack(coords + forward * 1.0)
  1180.  
  1181.             if model == 'prop_roadcone02a' then
  1182.               z = z - 2.0
  1183.             end
  1184.  
  1185.             ESX.Game.SpawnObject(model, {
  1186.               x = x,
  1187.               y = y,
  1188.               z = z
  1189.             }, function(obj)
  1190.               SetEntityHeading(obj, GetEntityHeading(playerPed))
  1191.               PlaceObjectOnGroundProperly(obj)
  1192.             end)
  1193.  
  1194.           end,
  1195.           function(data2, menu2)
  1196.             menu2.close()
  1197.           end
  1198.         )
  1199.  
  1200.       end
  1201.  
  1202.     end,
  1203.     function(data, menu)
  1204.  
  1205.       menu.close()
  1206.  
  1207.     end
  1208.   )
  1209.  
  1210. end
  1211.  
  1212. function OpenIdentityCardMenu(player)
  1213.  
  1214.   if Config.EnableESXIdentity then
  1215.  
  1216.     ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data)
  1217.  
  1218.       local jobLabel    = nil
  1219.       local sexLabel    = nil
  1220.       local sex         = nil
  1221.       local dobLabel    = nil
  1222.       local heightLabel = nil
  1223.       local idLabel     = nil
  1224.  
  1225.       if data.job.grade_label ~= nil and  data.job.grade_label ~= '' then
  1226.         jobLabel = 'Job : ' .. data.job.label .. ' - ' .. data.job.grade_label
  1227.       else
  1228.         jobLabel = 'Job : ' .. data.job.label
  1229.       end
  1230.  
  1231.       if data.sex ~= nil then
  1232.         if (data.sex == 'm') or (data.sex == 'M') then
  1233.           sex = 'Male'
  1234.         else
  1235.           sex = 'Female'
  1236.         end
  1237.         sexLabel = 'Sex : ' .. sex
  1238.       else
  1239.         sexLabel = 'Sex : Unknown'
  1240.       end
  1241.  
  1242.       if data.dob ~= nil then
  1243.         dobLabel = 'DOB : ' .. data.dob
  1244.       else
  1245.         dobLabel = 'DOB : Unknown'
  1246.       end
  1247.  
  1248.       if data.height ~= nil then
  1249.         heightLabel = 'Height : ' .. data.height
  1250.       else
  1251.         heightLabel = 'Height : Unknown'
  1252.       end
  1253.  
  1254.       if data.name ~= nil then
  1255.         idLabel = 'ID : ' .. data.name
  1256.       else
  1257.         idLabel = 'ID : Unknown'
  1258.       end
  1259.  
  1260.       local elements = {
  1261.         {label = _U('name') .. data.firstname .. " " .. data.lastname, value = nil},
  1262.         {label = sexLabel,    value = nil},
  1263.         {label = dobLabel,    value = nil},
  1264.         {label = heightLabel, value = nil},
  1265.         {label = jobLabel,    value = nil},
  1266.         {label = idLabel,     value = nil},
  1267.       }
  1268.  
  1269.       if data.drunk ~= nil then
  1270.         table.insert(elements, {label = _U('bac') .. data.drunk .. '%', value = nil})
  1271.       end
  1272.  
  1273.       if data.licenses ~= nil then
  1274.  
  1275.         table.insert(elements, {label = '--- Licenses ---', value = nil})
  1276.  
  1277.         for i=1, #data.licenses, 1 do
  1278.           table.insert(elements, {label = data.licenses[i].label, value = nil})
  1279.         end
  1280.  
  1281.       end
  1282.  
  1283.       ESX.UI.Menu.Open(
  1284.         'default', GetCurrentResourceName(), 'citizen_interaction',
  1285.         {
  1286.           title    = _U('citizen_interaction'),
  1287.           align    = 'top-left',
  1288.           elements = elements,
  1289.         },
  1290.         function(data, menu)
  1291.  
  1292.         end,
  1293.         function(data, menu)
  1294.           menu.close()
  1295.         end
  1296.       )
  1297.  
  1298.     end, GetPlayerServerId(player))
  1299.  
  1300.   else
  1301.  
  1302.     ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data)
  1303.  
  1304.       local jobLabel = nil
  1305.  
  1306.       if data.job.grade_label ~= nil and  data.job.grade_label ~= '' then
  1307.         jobLabel = 'Job : ' .. data.job.label .. ' - ' .. data.job.grade_label
  1308.       else
  1309.         jobLabel = 'Job : ' .. data.job.label
  1310.       end
  1311.  
  1312.         local elements = {
  1313.           {label = _U('name') .. data.name, value = nil},
  1314.           {label = jobLabel,              value = nil},
  1315.         }
  1316.  
  1317.       if data.drunk ~= nil then
  1318.         table.insert(elements, {label = _U('bac') .. data.drunk .. '%', value = nil})
  1319.       end
  1320.  
  1321.       if data.licenses ~= nil then
  1322.  
  1323.         table.insert(elements, {label = '--- Licenses ---', value = nil})
  1324.  
  1325.         for i=1, #data.licenses, 1 do
  1326.           table.insert(elements, {label = data.licenses[i].label, value = nil})
  1327.         end
  1328.  
  1329.       end
  1330.  
  1331.       ESX.UI.Menu.Open(
  1332.         'default', GetCurrentResourceName(), 'citizen_interaction',
  1333.         {
  1334.           title    = _U('citizen_interaction'),
  1335.           align    = 'top-left',
  1336.           elements = elements,
  1337.         },
  1338.         function(data, menu)
  1339.  
  1340.         end,
  1341.         function(data, menu)
  1342.           menu.close()
  1343.         end
  1344.       )
  1345.  
  1346.     end, GetPlayerServerId(player))
  1347.  
  1348.   end
  1349.  
  1350. end
  1351.  
  1352. function OpenBodySearchMenu(player)
  1353.  
  1354.   ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data)
  1355.  
  1356.     local elements = {}
  1357.  
  1358.     local blackMoney = 0
  1359.  
  1360.     for i=1, #data.accounts, 1 do
  1361.       if data.accounts[i].name == 'black_money' then
  1362.         blackMoney = data.accounts[i].money
  1363.       end
  1364.     end
  1365.  
  1366.     table.insert(elements, {
  1367.       label          = _U('confiscate_dirty') .. blackMoney,
  1368.       value          = 'black_money',
  1369.       itemType       = 'item_account',
  1370.       amount         = blackMoney
  1371.     })
  1372.  
  1373.     table.insert(elements, {label = '--- Armes ---', value = nil})
  1374.  
  1375.     for i=1, #data.weapons, 1 do
  1376.       table.insert(elements, {
  1377.         label          = _U('confiscate') .. ESX.GetWeaponLabel(data.weapons[i].name),
  1378.         value          = data.weapons[i].name,
  1379.         itemType       = 'item_weapon',
  1380.         amount         = data.ammo,
  1381.       })
  1382.     end
  1383.  
  1384.     table.insert(elements, {label = _U('inventory_label'), value = nil})
  1385.  
  1386.     for i=1, #data.inventory, 1 do
  1387.       if data.inventory[i].count > 0 then
  1388.         table.insert(elements, {
  1389.           label          = _U('confiscate_inv') .. data.inventory[i].count .. ' ' .. data.inventory[i].label,
  1390.           value          = data.inventory[i].name,
  1391.           itemType       = 'item_standard',
  1392.           amount         = data.inventory[i].count,
  1393.         })
  1394.       end
  1395.     end
  1396.  
  1397.  
  1398.     ESX.UI.Menu.Open(
  1399.       'default', GetCurrentResourceName(), 'body_search',
  1400.       {
  1401.         title    = _U('search'),
  1402.         align    = 'top-left',
  1403.         elements = elements,
  1404.       },
  1405.       function(data, menu)
  1406.  
  1407.         local itemType = data.current.itemType
  1408.         local itemName = data.current.value
  1409.         local amount   = data.current.amount
  1410.  
  1411.         if data.current.value ~= nil then
  1412.  
  1413.           TriggerServerEvent('esx_policejob:confiscatePlayerItem', GetPlayerServerId(player), itemType, itemName, amount)
  1414.  
  1415.           OpenBodySearchMenu(player)
  1416.  
  1417.         end
  1418.  
  1419.       end,
  1420.       function(data, menu)
  1421.         menu.close()
  1422.       end
  1423.     )
  1424.  
  1425.   end, GetPlayerServerId(player))
  1426.  
  1427. end
  1428.  
  1429. function OpenFineMenu(player)
  1430.  
  1431.   ESX.UI.Menu.Open(
  1432.     'default', GetCurrentResourceName(), 'fine',
  1433.     {
  1434.       title    = _U('fine'),
  1435.       align    = 'top-left',
  1436.       elements = {
  1437.         {label = _U('traffic_offense'),   value = 0},
  1438.         {label = _U('minor_offense'),     value = 1},
  1439.         {label = _U('average_offense'),   value = 2},
  1440.         {label = _U('major_offense'),     value = 3}
  1441.       },
  1442.     },
  1443.     function(data, menu)
  1444.  
  1445.       OpenFineCategoryMenu(player, data.current.value)
  1446.  
  1447.     end,
  1448.     function(data, menu)
  1449.       menu.close()
  1450.     end
  1451.   )
  1452.  
  1453. end
  1454.  
  1455. function OpenFineCategoryMenu(player, category)
  1456.  
  1457.   ESX.TriggerServerCallback('esx_policejob:getFineList', function(fines)
  1458.  
  1459.     local elements = {}
  1460.  
  1461.     for i=1, #fines, 1 do
  1462.       table.insert(elements, {
  1463.         label     = fines[i].label .. ' $' .. fines[i].amount,
  1464.         value     = fines[i].id,
  1465.         amount    = fines[i].amount,
  1466.         fineLabel = fines[i].label
  1467.       })
  1468.     end
  1469.  
  1470.     ESX.UI.Menu.Open(
  1471.       'default', GetCurrentResourceName(), 'fine_category',
  1472.       {
  1473.         title    = _U('fine'),
  1474.         align    = 'top-left',
  1475.         elements = elements,
  1476.       },
  1477.       function(data, menu)
  1478.  
  1479.         local label  = data.current.fineLabel
  1480.         local amount = data.current.amount
  1481.  
  1482.         menu.close()
  1483.  
  1484.         if Config.EnablePlayerManagement then
  1485.           TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), 'society_police', _U('fine_total') .. label, amount)
  1486.         else
  1487.           TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), '', _U('fine_total') .. label, amount)
  1488.         end
  1489.  
  1490.         ESX.SetTimeout(300, function()
  1491.           OpenFineCategoryMenu(player, category)
  1492.         end)
  1493.  
  1494.       end,
  1495.       function(data, menu)
  1496.         menu.close()
  1497.       end
  1498.     )
  1499.  
  1500.   end, category)
  1501.  
  1502. end
  1503.  
  1504. function OpenVehicleInfosMenu(vehicleData)
  1505.  
  1506.   ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(infos)
  1507.  
  1508.     local elements = {}
  1509.  
  1510.     table.insert(elements, {label = _U('plate') .. infos.plate, value = nil})
  1511.  
  1512.     if infos.owner == nil then
  1513.       table.insert(elements, {label = _U('owner_unknown'), value = nil})
  1514.     else
  1515.       table.insert(elements, {label = _U('owner') .. infos.owner, value = nil})
  1516.     end
  1517.  
  1518.     ESX.UI.Menu.Open(
  1519.       'default', GetCurrentResourceName(), 'vehicle_infos',
  1520.       {
  1521.         title    = _U('vehicle_info'),
  1522.         align    = 'top-left',
  1523.         elements = elements,
  1524.       },
  1525.       nil,
  1526.       function(data, menu)
  1527.         menu.close()
  1528.       end
  1529.     )
  1530.  
  1531.   end, vehicleData.plate)
  1532.  
  1533. end
  1534.  
  1535. function OpenGetWeaponMenu()
  1536.  
  1537.   ESX.TriggerServerCallback('esx_policejob:getArmoryWeapons', function(weapons)
  1538.  
  1539.     local elements = {}
  1540.  
  1541.     for i=1, #weapons, 1 do
  1542.       if weapons[i].count > 0 then
  1543.         table.insert(elements, {label = 'x' .. weapons[i].count .. ' ' .. ESX.GetWeaponLabel(weapons[i].name), value = weapons[i].name})
  1544.       end
  1545.     end
  1546.  
  1547.     ESX.UI.Menu.Open(
  1548.       'default', GetCurrentResourceName(), 'armory_get_weapon',
  1549.       {
  1550.         title    = _U('get_weapon_menu'),
  1551.         align    = 'top-left',
  1552.         elements = elements,
  1553.       },
  1554.       function(data, menu)
  1555.  
  1556.         menu.close()
  1557.  
  1558.         ESX.TriggerServerCallback('esx_policejob:removeArmoryWeapon', function()
  1559.           OpenGetWeaponMenu()
  1560.         end, data.current.value)
  1561.  
  1562.       end,
  1563.       function(data, menu)
  1564.         menu.close()
  1565.       end
  1566.     )
  1567.  
  1568.   end)
  1569.  
  1570. end
  1571.  
  1572. function OpenPutWeaponMenu()
  1573.  
  1574.   local elements   = {}
  1575.   local playerPed  = GetPlayerPed(-1)
  1576.   local weaponList = ESX.GetWeaponList()
  1577.  
  1578.   for i=1, #weaponList, 1 do
  1579.  
  1580.     local weaponHash = GetHashKey(weaponList[i].name)
  1581.  
  1582.     if HasPedGotWeapon(playerPed,  weaponHash,  false) and weaponList[i].name ~= 'WEAPON_UNARMED' then
  1583.       local ammo = GetAmmoInPedWeapon(playerPed, weaponHash)
  1584.       table.insert(elements, {label = weaponList[i].label, value = weaponList[i].name})
  1585.     end
  1586.  
  1587.   end
  1588.  
  1589.   ESX.UI.Menu.Open(
  1590.     'default', GetCurrentResourceName(), 'armory_put_weapon',
  1591.     {
  1592.       title    = _U('put_weapon_menu'),
  1593.       align    = 'top-left',
  1594.       elements = elements,
  1595.     },
  1596.     function(data, menu)
  1597.  
  1598.       menu.close()
  1599.  
  1600.       ESX.TriggerServerCallback('esx_policejob:addArmoryWeapon', function()
  1601.         OpenPutWeaponMenu()
  1602.       end, data.current.value)
  1603.  
  1604.     end,
  1605.     function(data, menu)
  1606.       menu.close()
  1607.     end
  1608.   )
  1609.  
  1610. end
  1611.  
  1612. function OpenBuyWeaponsMenu(station)
  1613.  
  1614.   ESX.TriggerServerCallback('esx_policejob:getArmoryWeapons', function(weapons)
  1615.  
  1616.     local elements = {}
  1617.  
  1618.     for i=1, #Config.PoliceStations[station].AuthorizedWeapons, 1 do
  1619.  
  1620.       local weapon = Config.PoliceStations[station].AuthorizedWeapons[i]
  1621.       local count  = 0
  1622.  
  1623.       for i=1, #weapons, 1 do
  1624.         if weapons[i].name == weapon.name then
  1625.           count = weapons[i].count
  1626.           break
  1627.         end
  1628.       end
  1629.  
  1630.       table.insert(elements, {label = 'x' .. count .. ' ' .. ESX.GetWeaponLabel(weapon.name) .. ' $' .. weapon.price, value = weapon.name, price = weapon.price})
  1631.  
  1632.     end
  1633.  
  1634.     ESX.UI.Menu.Open(
  1635.       'default', GetCurrentResourceName(), 'armory_buy_weapons',
  1636.       {
  1637.         title    = _U('buy_weapon_menu'),
  1638.         align    = 'top-left',
  1639.         elements = elements,
  1640.       },
  1641.       function(data, menu)
  1642.  
  1643.         ESX.TriggerServerCallback('esx_policejob:buy', function(hasEnoughMoney)
  1644.  
  1645.           if hasEnoughMoney then
  1646.             ESX.TriggerServerCallback('esx_policejob:addArmoryWeapon', function()
  1647.               OpenBuyWeaponsMenu(station)
  1648.             end, data.current.value)
  1649.           else
  1650.             ESX.ShowNotification(_U('not_enough_money'))
  1651.           end
  1652.  
  1653.         end, data.current.price)
  1654.  
  1655.       end,
  1656.       function(data, menu)
  1657.         menu.close()
  1658.       end
  1659.     )
  1660.  
  1661.   end)
  1662.  
  1663. end
  1664.  
  1665. function OpenGetStocksMenu()
  1666.  
  1667.   ESX.TriggerServerCallback('esx_policejob:getStockItems', function(items)
  1668.  
  1669.     print(json.encode(items))
  1670.  
  1671.     local elements = {}
  1672.  
  1673.     for i=1, #items, 1 do
  1674.       table.insert(elements, {label = 'x' .. items[i].count .. ' ' .. items[i].label, value = items[i].name})
  1675.     end
  1676.  
  1677.     ESX.UI.Menu.Open(
  1678.       'default', GetCurrentResourceName(), 'stocks_menu',
  1679.       {
  1680.         title    = _U('police_stock'),
  1681.         elements = elements
  1682.       },
  1683.       function(data, menu)
  1684.  
  1685.         local itemName = data.current.value
  1686.  
  1687.         ESX.UI.Menu.Open(
  1688.           'dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count',
  1689.           {
  1690.             title = _U('quantity')
  1691.           },
  1692.           function(data2, menu2)
  1693.  
  1694.             local count = tonumber(data2.value)
  1695.  
  1696.             if count == nil then
  1697.               ESX.ShowNotification(_U('quantity_invalid'))
  1698.             else
  1699.               menu2.close()
  1700.               menu.close()
  1701.               OpenGetStocksMenu()
  1702.  
  1703.               TriggerServerEvent('esx_policejob:getStockItem', itemName, count)
  1704.             end
  1705.  
  1706.           end,
  1707.           function(data2, menu2)
  1708.             menu2.close()
  1709.           end
  1710.         )
  1711.  
  1712.       end,
  1713.       function(data, menu)
  1714.         menu.close()
  1715.       end
  1716.     )
  1717.  
  1718.   end)
  1719.  
  1720. end
  1721.  
  1722. function OpenPutStocksMenu()
  1723.  
  1724.   ESX.TriggerServerCallback('esx_policejob:getPlayerInventory', function(inventory)
  1725.  
  1726.     local elements = {}
  1727.  
  1728.     for i=1, #inventory.items, 1 do
  1729.  
  1730.       local item = inventory.items[i]
  1731.  
  1732.       if item.count > 0 then
  1733.         table.insert(elements, {label = item.label .. ' x' .. item.count, type = 'item_standard', value = item.name})
  1734.       end
  1735.  
  1736.     end
  1737.  
  1738.     ESX.UI.Menu.Open(
  1739.       'default', GetCurrentResourceName(), 'stocks_menu',
  1740.       {
  1741.         title    = _U('inventory'),
  1742.         elements = elements
  1743.       },
  1744.       function(data, menu)
  1745.  
  1746.         local itemName = data.current.value
  1747.  
  1748.         ESX.UI.Menu.Open(
  1749.           'dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count',
  1750.           {
  1751.             title = _U('quantity')
  1752.           },
  1753.           function(data2, menu2)
  1754.  
  1755.             local count = tonumber(data2.value)
  1756.  
  1757.             if count == nil then
  1758.               ESX.ShowNotification(_U('quantity_invalid'))
  1759.             else
  1760.               menu2.close()
  1761.               menu.close()
  1762.               OpenPutStocksMenu()
  1763.  
  1764.               TriggerServerEvent('esx_policejob:putStockItems', itemName, count)
  1765.             end
  1766.  
  1767.           end,
  1768.           function(data2, menu2)
  1769.             menu2.close()
  1770.           end
  1771.         )
  1772.  
  1773.       end,
  1774.       function(data, menu)
  1775.         menu.close()
  1776.       end
  1777.     )
  1778.  
  1779.   end)
  1780.  
  1781. end
  1782.  
  1783. RegisterNetEvent('esx:playerLoaded')
  1784. AddEventHandler('esx:playerLoaded', function(xPlayer)
  1785.   PlayerData = xPlayer
  1786. end)
  1787.  
  1788. RegisterNetEvent('esx:setJob')
  1789. AddEventHandler('esx:setJob', function(job)
  1790.   PlayerData.job = job
  1791. end)
  1792.  
  1793. RegisterNetEvent('esx_phone:loaded')
  1794. AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts)
  1795.  
  1796.   local specialContact = {
  1797.     name       = 'Police',
  1798.     number     = 'police',
  1799.     base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NDFGQTJDRkI0QUJCMTFFN0JBNkQ5OENBMUI4QUEzM0YiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDFGQTJDRkM0QUJCMTFFN0JBNkQ5OENBMUI4QUEzM0YiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0MUZBMkNGOTRBQkIxMUU3QkE2RDk4Q0ExQjhBQTMzRiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo0MUZBMkNGQTRBQkIxMUU3QkE2RDk4Q0ExQjhBQTMzRiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoW66EYAAAjGSURBVHjapJcLcFTVGcd/u3cfSXaTLEk2j80TCI8ECI9ABCyoiBqhBVQqVG2ppVKBQqUVgUl5OU7HKqNOHUHU0oHamZZWoGkVS6cWAR2JPJuAQBPy2ISEvLN57+v2u2E33e4k6Ngz85+9d++95/zP9/h/39GpqsqiRYsIGz8QZAq28/8PRfC+4HT4fMXFxeiH+GC54NeCbYLLATLpYe/ECx4VnBTsF0wWhM6lXY8VbBE0Ch4IzLcpfDFD2P1TgrdC7nMCZLRxQ9AkiAkQCn77DcH3BC2COoFRkCSIG2JzLwqiQi0RSmCD4JXbmNKh0+kc/X19tLtc9Ll9sk9ZS1yoU71YIk3xsbEx8QaDEc2ttxmaJSKC1ggSKBK8MKwTFQVXRzs3WzpJGjmZgvxcMpMtWIwqsjztvSrlzjYul56jp+46qSmJmMwR+P3+4aZ8TtCprRkk0DvUW7JjmV6lsqoKW/pU1q9YQOE4Nxkx4ladE7zd8ivuVmJQfXZKW5dx5EwPRw4fxNx2g5SUVLw+33AkzoRaQDP9SkFu6OKqz0uF8yaz7vsOL6ycQVLkcSg/BlWNsjuFoKE1knqDSl5aNnmPLmThrE0UvXqQqvJPyMrMGorEHwQfEha57/3P7mXS684GFjy8kreLppPUuBXfyd/ibeoS2kb0mWPANhJdYjb61AxUvx5PdT3+4y+Tb3mTd19ZSebE+VTXVGNQlHAC7w4VhH8TbA36vKq6ilnzlvPSunHw6Trc7XpZ14AyfgYeyz18crGN1Alz6e3qwNNQSv4dZox1h/BW9+O7eIaEsVv41Y4XeHJDG83Nl4mLTwzGhJYtx0PzNTjOB9KMTlc7Nkcem39YAGU7cbeBKVLMPGMVf296nMd2VbBq1wmizHoqqm/wrS1/Zf0+N19YN2PIu1fcIda4Vk66Zx/rVi+jo9eIX9wZGGcFXUMR6BHUa76/2ezioYcXMtpyAl91DSaTfDxlJbtLprHm2ecpObqPuTPzSNV9yKz4a4zJSuLo71/j8Q17ON69EmXiPIlNMe6FoyzOqWPW/MU03Lw5EFcyKghTrNDh7+/vw545mcJcWbTiGKpRdGPMXbx90sGmDaux6sXk+kimjU+BjnMkx3kYP34cXrFuZ+3nrHi6iDMt92JITcPjk3R3naRwZhpuNSqoD93DKaFVU7j2dhcF8+YzNlpErbIBTVh8toVccbaysPB+4pMcuPw25kwSsau7BIlmHpy3guaOPtISYyi/UkaJM5Lpc5agq5Xkcl6gIHkmqaMn0dtylcjIyPThCNyhaXyfR2W0I1our0v6qBii07ih5rDtGSOxNVdk1y4R2SR8jR/g7hQD9l1jUeY/WLJB5m39AlZN4GZyIQ1fFJNsEgt0duBIc5GRkcZF53mNwIzhXPDgQPoZIkiMkbTxtstDMVnmFA4cOsbz2/aKjSQjev4Mp9ZAg+hIpFhB3EH5Yal16+X+Kq3dGfxkzRY+KauBjBzREvGN0kNCTARu94AejBLMHorAQ7cEQMGs2cXvkWshYLDi6e9l728O8P1XW6hKeB2yv42q18tjj+iFTGoSi+X9jJM9RTxS9E+OHT0krhNiZqlbqraoT7RAU5bBGrEknEBhgJks7KXbLS8qERI0ErVqF/Y4K6NHZfLZB+/wzJvncacvFd91oXO3o/O40MfZKJOKu/rne+mRQByXM4lYreb1tUnkizVVA/0SpfpbWaCNBeEE5gb/UH19NLqEgDF+oNDQWcn41Cj0EXFEWqzkOIyYekslFkThsvMxpIyE2hIc6lXGZ6cPyK7Nnk5OipixRdxgUESAYmhq68VsGgy5CYKCUAJTg0+izApXne3CJFmUTwg4L3FProFxU+6krqmXu3MskkhSD2av41jLdzlnfFrSdCZxyqfMnppN6ZUa7pwt0h3fiK9DCt4IO9e7YqisvI7VYgmNv7mhBKKD/9psNi5dOMv5ZjukjsLdr0ffWsyTi6eSlfcA+dmiVyOXs+/sHNZu3M6PdxzgVO9GmDSHsSNqmTz/R6y6Xxqma4fwaS5Mn85n1ZE0Vl3CHBER3lUNEhiURpPJRFdTOcVnpUJnPIhR7cZXfoH5UYc5+E4RzRH3sfSnl9m2dSMjE+Tz9msse+o5dr7UwcQ5T3HwlWUkNuzG3dKFSTbsNs7m/Y8vExOlC29UWkMJlAxKoRQMR3IC7x85zOn6fHS50+U/2Untx2R1voinu5no+DQmz7yPXmMKZnsu0wrm0Oe3YhOVHdm8A09dBQYhTv4T7C+xUPrZh8Qn2MMr4qcDSRfoirWgKAvtgOpv1JI8Zi77X15G7L+fxeOUOiUFxZiULD5fSlNzNM62W+k1yq5gjajGX/ZHvOIyxd+Fkj+P092rWP/si0Qr7VisMaEWuCiYonXFwbAUTWWPYLV245NITnGkUXnpI9butLJn2y6iba+hlp7C09qBcvoN7FYL9mhxo1/y/LoEXK8Pv6qIC8WbBY/xr9YlPLf9dZT+OqKTUwfmDBm/GOw7ws4FWpuUP2gJEZvKqmocuXPZuWYJMzKuSsH+SNwh3bo0p6hao6HeEqwYEZ2M6aKWd3PwTCy7du/D0F1DsmzE6/WGLr5LsDF4LggnYBacCOboQLHQ3FFfR58SR+HCR1iQH8ukhA5s5o5AYZMwUqOp74nl8xvRHDlRTsnxYpJsUjtsceHt2C8Fm0MPJrphTkZvBc4It9RKLOFx91Pf0Igu0k7W2MmkOewS2QYJUJVWVz9VNbXUVVwkyuAmKTFJayrDo/4Jwe/CT0aGYTrWVYEeUfsgXssMRcpyenraQJa0VX9O3ZU+Ma1fax4xGxUsUVFkOUbcama1hf+7+LmA9juHWshwmwOE1iMmCFYEzg1jtIm1BaxW6wCGGoFdewPfvyE4ertTiv4rHC73B855dwp2a23bbd4tC1hvhOCbX7b4VyUQKhxrtSOaYKngasizvwi0RmOS4O1QZf2yYfiaR+73AvhTQEVf+rpn9/8IMAChKDrDzfsdIQAAAABJRU5ErkJggg=='
  1800.   }
  1801.  
  1802.   TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon)
  1803.  
  1804. end)
  1805.  
  1806. AddEventHandler('esx_policejob:hasEnteredMarker', function(station, part, partNum)
  1807.  
  1808.   if part == 'Cloakroom' then
  1809.     CurrentAction     = 'menu_cloakroom'
  1810.     CurrentActionMsg  = _U('open_cloackroom')
  1811.     CurrentActionData = {}
  1812.   end
  1813.  
  1814.   if part == 'Armory' then
  1815.     CurrentAction     = 'menu_armory'
  1816.     CurrentActionMsg  = _U('open_armory')
  1817.     CurrentActionData = {station = station}
  1818.   end
  1819.  
  1820.   if part == 'VehicleSpawner' then
  1821.     CurrentAction     = 'menu_vehicle_spawner'
  1822.     CurrentActionMsg  = _U('vehicle_spawner')
  1823.     CurrentActionData = {station = station, partNum = partNum}
  1824.   end
  1825.  
  1826.   if part == 'HelicopterSpawner' then
  1827.  
  1828.     local helicopters = Config.PoliceStations[station].Helicopters
  1829.  
  1830.     if not IsAnyVehicleNearPoint(helicopters[partNum].SpawnPoint.x, helicopters[partNum].SpawnPoint.y, helicopters[partNum].SpawnPoint.z,  3.0) then
  1831.  
  1832.       ESX.Game.SpawnVehicle('polmav', {
  1833.         x = helicopters[partNum].SpawnPoint.x,
  1834.         y = helicopters[partNum].SpawnPoint.y,
  1835.         z = helicopters[partNum].SpawnPoint.z
  1836.       }, helicopters[partNum].Heading, function(vehicle)
  1837.         SetVehicleModKit(vehicle, 0)
  1838.         SetVehicleLivery(vehicle, 0)
  1839.       end)
  1840.  
  1841.     end
  1842.  
  1843.   end
  1844.  
  1845.   if part == 'VehicleDeleter' then
  1846.  
  1847.     local playerPed = GetPlayerPed(-1)
  1848.     local coords    = GetEntityCoords(playerPed)
  1849.  
  1850.     if IsPedInAnyVehicle(playerPed,  false) then
  1851.  
  1852.       local vehicle = GetVehiclePedIsIn(playerPed, false)
  1853.  
  1854.       if DoesEntityExist(vehicle) then
  1855.         CurrentAction     = 'delete_vehicle'
  1856.         CurrentActionMsg  = _U('store_vehicle')
  1857.         CurrentActionData = {vehicle = vehicle}
  1858.       end
  1859.  
  1860.     end
  1861.  
  1862.   end
  1863.  
  1864.   if part == 'BossActions' then
  1865.     CurrentAction     = 'menu_boss_actions'
  1866.     CurrentActionMsg  = _U('open_bossmenu')
  1867.     CurrentActionData = {}
  1868.   end
  1869.  
  1870. end)
  1871.  
  1872. AddEventHandler('esx_policejob:hasExitedMarker', function(station, part, partNum)
  1873.   ESX.UI.Menu.CloseAll()
  1874.   CurrentAction = nil
  1875. end)
  1876.  
  1877. AddEventHandler('esx_policejob:hasEnteredEntityZone', function(entity)
  1878.  
  1879.   local playerPed = GetPlayerPed(-1)
  1880.  
  1881.   if PlayerData.job ~= nil and PlayerData.job.name == 'police' and not IsPedInAnyVehicle(playerPed, false) then
  1882.     CurrentAction     = 'remove_entity'
  1883.     CurrentActionMsg  = _U('remove_object')
  1884.     CurrentActionData = {entity = entity}
  1885.   end
  1886.  
  1887.   if GetEntityModel(entity) == GetHashKey('p_ld_stinger_s') then
  1888.  
  1889.     local playerPed = GetPlayerPed(-1)
  1890.     local coords    = GetEntityCoords(playerPed)
  1891.  
  1892.     if IsPedInAnyVehicle(playerPed,  false) then
  1893.  
  1894.       local vehicle = GetVehiclePedIsIn(playerPed)
  1895.  
  1896.       for i=0, 7, 1 do
  1897.         SetVehicleTyreBurst(vehicle,  i,  true,  1000)
  1898.       end
  1899.  
  1900.     end
  1901.  
  1902.   end
  1903.  
  1904. end)
  1905.  
  1906. AddEventHandler('esx_policejob:hasExitedEntityZone', function(entity)
  1907.  
  1908.   if CurrentAction == 'remove_entity' then
  1909.     CurrentAction = nil
  1910.   end
  1911.  
  1912. end)
  1913.  
  1914. RegisterNetEvent('esx_policejob:handcuff')
  1915. AddEventHandler('esx_policejob:handcuff', function()
  1916.  
  1917.   IsHandcuffed    = not IsHandcuffed;
  1918.   local playerPed = GetPlayerPed(-1)
  1919.  
  1920.   Citizen.CreateThread(function()
  1921.  
  1922.     if IsHandcuffed then
  1923.  
  1924.       RequestAnimDict('mp_arresting')
  1925.  
  1926.       while not HasAnimDictLoaded('mp_arresting') do
  1927.         Wait(100)
  1928.       end
  1929.  
  1930.       TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0, 0, 0, 0)
  1931.       SetEnableHandcuffs(playerPed, true)
  1932.       SetPedCanPlayGestureAnims(playerPed, false)
  1933.       FreezeEntityPosition(playerPed,  true)
  1934.  
  1935.     else
  1936.  
  1937.       ClearPedSecondaryTask(playerPed)
  1938.       SetEnableHandcuffs(playerPed, false)
  1939.       SetPedCanPlayGestureAnims(playerPed,  true)
  1940.       FreezeEntityPosition(playerPed, false)
  1941.  
  1942.     end
  1943.  
  1944.   end)
  1945. end)
  1946.  
  1947. RegisterNetEvent('esx_policejob:drag')
  1948. AddEventHandler('esx_policejob:drag', function(cop)
  1949.   TriggerServerEvent('esx:clientLog', 'starting dragging')
  1950.   IsDragged = not IsDragged
  1951.   CopPed = tonumber(cop)
  1952. end)
  1953.  
  1954. Citizen.CreateThread(function()
  1955.   while true do
  1956.     Wait(0)
  1957.     if IsHandcuffed then
  1958.       if IsDragged then
  1959.         local ped = GetPlayerPed(GetPlayerFromServerId(CopPed))
  1960.         local myped = GetPlayerPed(-1)
  1961.         AttachEntityToEntity(myped, ped, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
  1962.       else
  1963.         DetachEntity(GetPlayerPed(-1), true, false)
  1964.       end
  1965.     end
  1966.   end
  1967. end)
  1968.  
  1969. RegisterNetEvent('esx_policejob:putInVehicle')
  1970. AddEventHandler('esx_policejob:putInVehicle', function()
  1971.  
  1972.   local playerPed = GetPlayerPed(-1)
  1973.   local coords    = GetEntityCoords(playerPed)
  1974.  
  1975.   if IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 5.0) then
  1976.  
  1977.     local vehicle = GetClosestVehicle(coords.x,  coords.y,  coords.z,  5.0,  0,  71)
  1978.  
  1979.     if DoesEntityExist(vehicle) then
  1980.  
  1981.       local maxSeats = GetVehicleMaxNumberOfPassengers(vehicle)
  1982.       local freeSeat = nil
  1983.  
  1984.       for i=maxSeats - 1, 0, -1 do
  1985.         if IsVehicleSeatFree(vehicle,  i) then
  1986.           freeSeat = i
  1987.           break
  1988.         end
  1989.       end
  1990.  
  1991.       if freeSeat ~= nil then
  1992.         TaskWarpPedIntoVehicle(playerPed,  vehicle,  freeSeat)
  1993.       end
  1994.  
  1995.     end
  1996.  
  1997.   end
  1998.  
  1999. end)
  2000.  
  2001. RegisterNetEvent('esx_policejob:OutVehicle')
  2002. AddEventHandler('esx_policejob:OutVehicle', function(t)
  2003.   local ped = GetPlayerPed(t)
  2004.   ClearPedTasksImmediately(ped)
  2005.   plyPos = GetEntityCoords(GetPlayerPed(-1),  true)
  2006.   local xnew = plyPos.x+2
  2007.   local ynew = plyPos.y+2
  2008.  
  2009.   SetEntityCoords(GetPlayerPed(-1), xnew, ynew, plyPos.z)
  2010. end)
  2011.  
  2012. -- Handcuff
  2013. Citizen.CreateThread(function()
  2014.   while true do
  2015.     Wait(0)
  2016.     if IsHandcuffed then
  2017.       DisableControlAction(0, 142, true) -- MeleeAttackAlternate
  2018.       DisableControlAction(0, 30,  true) -- MoveLeftRight
  2019.       DisableControlAction(0, 31,  true) -- MoveUpDown
  2020.     end
  2021.   end
  2022. end)
  2023.  
  2024. -- Create blips
  2025. Citizen.CreateThread(function()
  2026.  
  2027.   for k,v in pairs(Config.PoliceStations) do
  2028.  
  2029.     local blip = AddBlipForCoord(v.Blip.Pos.x, v.Blip.Pos.y, v.Blip.Pos.z)
  2030.  
  2031.     SetBlipSprite (blip, v.Blip.Sprite)
  2032.     SetBlipDisplay(blip, v.Blip.Display)
  2033.     SetBlipScale  (blip, v.Blip.Scale)
  2034.     SetBlipColour (blip, v.Blip.Colour)
  2035.     SetBlipAsShortRange(blip, true)
  2036.  
  2037.     BeginTextCommandSetBlipName("STRING")
  2038.     AddTextComponentString(_U('map_blip'))
  2039.     EndTextCommandSetBlipName(blip)
  2040.  
  2041.   end
  2042.  
  2043. end)
  2044.  
  2045. -- Display markers
  2046. Citizen.CreateThread(function()
  2047.   while true do
  2048.  
  2049.     Wait(0)
  2050.  
  2051.     if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
  2052.  
  2053.       local playerPed = GetPlayerPed(-1)
  2054.       local coords    = GetEntityCoords(playerPed)
  2055.  
  2056.       for k,v in pairs(Config.PoliceStations) do
  2057.  
  2058.         for i=1, #v.Cloakrooms, 1 do
  2059.           if GetDistanceBetweenCoords(coords,  v.Cloakrooms[i].x,  v.Cloakrooms[i].y,  v.Cloakrooms[i].z,  true) < Config.DrawDistance then
  2060.             DrawMarker(Config.MarkerType, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  2061.           end
  2062.         end
  2063.  
  2064.         for i=1, #v.Armories, 1 do
  2065.           if GetDistanceBetweenCoords(coords,  v.Armories[i].x,  v.Armories[i].y,  v.Armories[i].z,  true) < Config.DrawDistance then
  2066.             DrawMarker(Config.MarkerType, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  2067.           end
  2068.         end
  2069.  
  2070.         for i=1, #v.Vehicles, 1 do
  2071.           if GetDistanceBetweenCoords(coords,  v.Vehicles[i].Spawner.x,  v.Vehicles[i].Spawner.y,  v.Vehicles[i].Spawner.z,  true) < Config.DrawDistance then
  2072.             DrawMarker(Config.MarkerType, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  2073.           end
  2074.         end
  2075.  
  2076.         for i=1, #v.VehicleDeleters, 1 do
  2077.           if GetDistanceBetweenCoords(coords,  v.VehicleDeleters[i].x,  v.VehicleDeleters[i].y,  v.VehicleDeleters[i].z,  true) < Config.DrawDistance then
  2078.             DrawMarker(Config.MarkerType, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  2079.           end
  2080.         end
  2081.  
  2082.         if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.name == 'police' and PlayerData.job.grade_name == 'boss' then
  2083.  
  2084.           for i=1, #v.BossActions, 1 do
  2085.             if not v.BossActions[i].disabled and GetDistanceBetweenCoords(coords,  v.BossActions[i].x,  v.BossActions[i].y,  v.BossActions[i].z,  true) < Config.DrawDistance then
  2086.               DrawMarker(Config.MarkerType, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  2087.             end
  2088.           end
  2089.  
  2090.         end
  2091.  
  2092.       end
  2093.  
  2094.     end
  2095.  
  2096.   end
  2097. end)
  2098.  
  2099. -- Enter / Exit marker events
  2100. Citizen.CreateThread(function()
  2101.  
  2102.   while true do
  2103.  
  2104.     Wait(0)
  2105.  
  2106.     if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
  2107.  
  2108.       local playerPed      = GetPlayerPed(-1)
  2109.       local coords         = GetEntityCoords(playerPed)
  2110.       local isInMarker     = false
  2111.       local currentStation = nil
  2112.       local currentPart    = nil
  2113.       local currentPartNum = nil
  2114.  
  2115.       for k,v in pairs(Config.PoliceStations) do
  2116.  
  2117.         for i=1, #v.Cloakrooms, 1 do
  2118.           if GetDistanceBetweenCoords(coords,  v.Cloakrooms[i].x,  v.Cloakrooms[i].y,  v.Cloakrooms[i].z,  true) < Config.MarkerSize.x then
  2119.             isInMarker     = true
  2120.             currentStation = k
  2121.             currentPart    = 'Cloakroom'
  2122.             currentPartNum = i
  2123.           end
  2124.         end
  2125.  
  2126.         for i=1, #v.Armories, 1 do
  2127.           if GetDistanceBetweenCoords(coords,  v.Armories[i].x,  v.Armories[i].y,  v.Armories[i].z,  true) < Config.MarkerSize.x then
  2128.             isInMarker     = true
  2129.             currentStation = k
  2130.             currentPart    = 'Armory'
  2131.             currentPartNum = i
  2132.           end
  2133.         end
  2134.  
  2135.         for i=1, #v.Vehicles, 1 do
  2136.  
  2137.           if GetDistanceBetweenCoords(coords,  v.Vehicles[i].Spawner.x,  v.Vehicles[i].Spawner.y,  v.Vehicles[i].Spawner.z,  true) < Config.MarkerSize.x then
  2138.             isInMarker     = true
  2139.             currentStation = k
  2140.             currentPart    = 'VehicleSpawner'
  2141.             currentPartNum = i
  2142.           end
  2143.  
  2144.           if GetDistanceBetweenCoords(coords,  v.Vehicles[i].SpawnPoint.x,  v.Vehicles[i].SpawnPoint.y,  v.Vehicles[i].SpawnPoint.z,  true) < Config.MarkerSize.x then
  2145.             isInMarker     = true
  2146.             currentStation = k
  2147.             currentPart    = 'VehicleSpawnPoint'
  2148.             currentPartNum = i
  2149.           end
  2150.  
  2151.         end
  2152.  
  2153.         for i=1, #v.Helicopters, 1 do
  2154.  
  2155.           if GetDistanceBetweenCoords(coords,  v.Helicopters[i].Spawner.x,  v.Helicopters[i].Spawner.y,  v.Helicopters[i].Spawner.z,  true) < Config.MarkerSize.x then
  2156.             isInMarker     = true
  2157.             currentStation = k
  2158.             currentPart    = 'HelicopterSpawner'
  2159.             currentPartNum = i
  2160.           end
  2161.  
  2162.           if GetDistanceBetweenCoords(coords,  v.Helicopters[i].SpawnPoint.x,  v.Helicopters[i].SpawnPoint.y,  v.Helicopters[i].SpawnPoint.z,  true) < Config.MarkerSize.x then
  2163.             isInMarker     = true
  2164.             currentStation = k
  2165.             currentPart    = 'HelicopterSpawnPoint'
  2166.             currentPartNum = i
  2167.           end
  2168.  
  2169.         end
  2170.  
  2171.         for i=1, #v.VehicleDeleters, 1 do
  2172.           if GetDistanceBetweenCoords(coords,  v.VehicleDeleters[i].x,  v.VehicleDeleters[i].y,  v.VehicleDeleters[i].z,  true) < Config.MarkerSize.x then
  2173.             isInMarker     = true
  2174.             currentStation = k
  2175.             currentPart    = 'VehicleDeleter'
  2176.             currentPartNum = i
  2177.           end
  2178.         end
  2179.  
  2180.         if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.name == 'police' and PlayerData.job.grade_name == 'boss' then
  2181.  
  2182.           for i=1, #v.BossActions, 1 do
  2183.             if GetDistanceBetweenCoords(coords,  v.BossActions[i].x,  v.BossActions[i].y,  v.BossActions[i].z,  true) < Config.MarkerSize.x then
  2184.               isInMarker     = true
  2185.               currentStation = k
  2186.               currentPart    = 'BossActions'
  2187.               currentPartNum = i
  2188.             end
  2189.           end
  2190.  
  2191.         end
  2192.  
  2193.       end
  2194.  
  2195.       local hasExited = false
  2196.  
  2197.       if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum) ) then
  2198.  
  2199.         if
  2200.           (LastStation ~= nil and LastPart ~= nil and LastPartNum ~= nil) and
  2201.           (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum)
  2202.         then
  2203.           TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum)
  2204.           hasExited = true
  2205.         end
  2206.  
  2207.         HasAlreadyEnteredMarker = true
  2208.         LastStation             = currentStation
  2209.         LastPart                = currentPart
  2210.         LastPartNum             = currentPartNum
  2211.  
  2212.         TriggerEvent('esx_policejob:hasEnteredMarker', currentStation, currentPart, currentPartNum)
  2213.       end
  2214.  
  2215.       if not hasExited and not isInMarker and HasAlreadyEnteredMarker then
  2216.  
  2217.         HasAlreadyEnteredMarker = false
  2218.  
  2219.         TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum)
  2220.       end
  2221.  
  2222.     end
  2223.  
  2224.   end
  2225. end)
  2226.  
  2227. -- Enter / Exit entity zone events
  2228. Citizen.CreateThread(function()
  2229.  
  2230.   local trackedEntities = {
  2231.     'prop_roadcone02a',
  2232.     'prop_barrier_work06a',
  2233.     'p_ld_stinger_s',
  2234.     'prop_boxpile_07d',
  2235.     'hei_prop_cash_crate_half_full'
  2236.   }
  2237.  
  2238.   while true do
  2239.  
  2240.     Citizen.Wait(0)
  2241.  
  2242.     local playerPed = GetPlayerPed(-1)
  2243.     local coords    = GetEntityCoords(playerPed)
  2244.  
  2245.     local closestDistance = -1
  2246.     local closestEntity   = nil
  2247.  
  2248.     for i=1, #trackedEntities, 1 do
  2249.  
  2250.       local object = GetClosestObjectOfType(coords.x,  coords.y,  coords.z,  3.0,  GetHashKey(trackedEntities[i]), false, false, false)
  2251.  
  2252.       if DoesEntityExist(object) then
  2253.  
  2254.         local objCoords = GetEntityCoords(object)
  2255.         local distance  = GetDistanceBetweenCoords(coords.x,  coords.y,  coords.z,  objCoords.x,  objCoords.y,  objCoords.z,  true)
  2256.  
  2257.         if closestDistance == -1 or closestDistance > distance then
  2258.           closestDistance = distance
  2259.           closestEntity   = object
  2260.         end
  2261.  
  2262.       end
  2263.  
  2264.     end
  2265.  
  2266.     if closestDistance ~= -1 and closestDistance <= 3.0 then
  2267.  
  2268.       if LastEntity ~= closestEntity then
  2269.         TriggerEvent('esx_policejob:hasEnteredEntityZone', closestEntity)
  2270.         LastEntity = closestEntity
  2271.       end
  2272.  
  2273.     else
  2274.  
  2275.       if LastEntity ~= nil then
  2276.         TriggerEvent('esx_policejob:hasExitedEntityZone', LastEntity)
  2277.         LastEntity = nil
  2278.       end
  2279.  
  2280.     end
  2281.  
  2282.   end
  2283. end)
  2284.  
  2285. function openPolice()
  2286.   if PlayerData.job ~= nil and PlayerData.job.name == 'police' and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'police_actions') and (GetGameTimer() - GUI.Time) > 150 then
  2287.     OpenPoliceActionsMenu()
  2288.     GUI.Time = GetGameTimer()
  2289.   end
  2290. end
  2291.  
  2292. function getJob()
  2293.   if PlayerData.job ~= nil then
  2294.         return PlayerData.job.name
  2295.   end
  2296. end
  2297.  
  2298. -- Key Controls
  2299. Citizen.CreateThread(function()
  2300.   while true do
  2301.  
  2302.     Citizen.Wait(0)
  2303.  
  2304.     if CurrentAction ~= nil then
  2305.  
  2306.       SetTextComponentFormat('STRING')
  2307.       AddTextComponentString(CurrentActionMsg)
  2308.       DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  2309.  
  2310.       if IsControlPressed(0,  Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'police' and (GetGameTimer() - GUI.Time) > 150 then
  2311.  
  2312.         if CurrentAction == 'menu_cloakroom' then
  2313.           OpenCloakroomMenu()
  2314.         end
  2315.  
  2316.         if CurrentAction == 'menu_armory' then
  2317.           OpenArmoryMenu(CurrentActionData.station)
  2318.         end
  2319.  
  2320.         if CurrentAction == 'menu_vehicle_spawner' then
  2321.           OpenVehicleSpawnerMenu(CurrentActionData.station, CurrentActionData.partNum)
  2322.         end
  2323.  
  2324.         if CurrentAction == 'delete_vehicle' then
  2325.  
  2326.           if Config.EnableSocietyOwnedVehicles then
  2327.  
  2328.             local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
  2329.             TriggerServerEvent('esx_society:putVehicleInGarage', 'police', vehicleProps)
  2330.  
  2331.           else
  2332.  
  2333.             if
  2334.               GetEntityModel(vehicle) == GetHashKey('police')  or
  2335.               GetEntityModel(vehicle) == GetHashKey('police2') or
  2336.               GetEntityModel(vehicle) == GetHashKey('police3') or
  2337.               GetEntityModel(vehicle) == GetHashKey('police4') or
  2338.               GetEntityModel(vehicle) == GetHashKey('policeb') or
  2339.               GetEntityModel(vehicle) == GetHashKey('policet')
  2340.             then
  2341.               TriggerServerEvent('esx_service:disableService', 'police')
  2342.             end
  2343.  
  2344.           end
  2345.  
  2346.           ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
  2347.         end
  2348.  
  2349.         if CurrentAction == 'menu_boss_actions' then
  2350.  
  2351.           ESX.UI.Menu.CloseAll()
  2352.  
  2353.           TriggerEvent('esx_society:openBossMenu', 'police', function(data, menu)
  2354.  
  2355.             menu.close()
  2356.  
  2357.             CurrentAction     = 'menu_boss_actions'
  2358.             CurrentActionMsg  = _U('open_bossmenu')
  2359.             CurrentActionData = {}
  2360.  
  2361.           end)
  2362.  
  2363.         end
  2364.  
  2365.         if CurrentAction == 'remove_entity' then
  2366.           DeleteEntity(CurrentActionData.entity)
  2367.         end
  2368.  
  2369.         CurrentAction = nil
  2370.         GUI.Time      = GetGameTimer()
  2371.  
  2372.       end
  2373.  
  2374.     end
  2375.  
  2376.     if IsControlPressed(0,  Keys['F6']) and PlayerData.job ~= nil and PlayerData.job.name == 'police' and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'police_actions') and (GetGameTimer() - GUI.Time) > 150 then
  2377.       OpenPoliceActionsMenu()
  2378.       GUI.Time = GetGameTimer()
  2379.     end
  2380.  
  2381.   end
  2382. end)
  2383.