Guest User

Untitled

a guest
Feb 16th, 2020
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. local open = false
  2. local ESX = nil
  3.  
  4. -- ESX
  5. -- Added this so you can include the rest of the Usage-stuff found on the GitHub page
  6. Citizen.CreateThread(function()
  7. while ESX == nil do
  8. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  9. Citizen.Wait(0)
  10. end
  11. end)
  12.  
  13. -- Open ID card
  14. RegisterNetEvent('jsfour-idcard:open')
  15. AddEventHandler('jsfour-idcard:open', function( data, type )
  16. open = true
  17. SendNUIMessage({
  18. action = "open",
  19. array = data,
  20. type = type
  21. })
  22. end)
  23.  
  24. -- Key events
  25. Citizen.CreateThread(function()
  26. while true do
  27. Wait(0)
  28. -- Controls found in the FiveM docs:
  29. -- https://docs.fivem.net/game-references/controls/
  30.  
  31. -- 38 = E
  32. if IsControlJustReleased(0, 57) then
  33. function openMenu()
  34. ESX.UI.Menu.Open(
  35. 'default', GetCurrentResourceName(), 'id_card_menu',
  36. {
  37. title = 'ID menu',
  38. elements = {
  39. {label = 'Check your ID', value = 'checkID'},
  40. {label = 'Show your ID', value = 'showID'},
  41. {label = 'Check your driver license', value = 'checkDriver'},
  42. {label = 'Show your driver license', value = 'showDriver'},
  43. {label = 'Check your firearms license', value = 'checkFirearms'},
  44. {label = 'Show your firearms license', value = 'showFirearms'},
  45. }
  46. },
  47. function(data, menu)
  48. local val = data.current.value
  49.  
  50. if val == 'checkID' then
  51. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
  52. elseif val == 'checkDriver' then
  53. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')
  54. elseif val == 'checkFirearms' then
  55. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'weapon')
  56. else
  57. local player, distance = ESX.Game.GetClosestPlayer()
  58.  
  59. if distance ~= -1 and distance <= 3.0 then
  60. if val == 'showID' then
  61. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
  62. elseif val == 'showDriver' then
  63. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
  64. elseif val == 'showFirearms' then
  65. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'weapon')
  66. end
  67. else
  68. ESX.ShowNotification('No players nearby')
  69. end
  70. end
  71. end,
  72. function(data, menu)
  73. menu.close()
  74. end
  75. )
  76. end
  77.  
  78. end
  79. end
  80. end)
Advertisement
Add Comment
Please, Sign In to add comment