Skip to content

Instantly share code, notes, and snippets.

@FiveEYZ
Created May 14, 2020 18:24
Show Gist options
  • Save FiveEYZ/a0bd44625c0514d2196025301dc91df0 to your computer and use it in GitHub Desktop.
Save FiveEYZ/a0bd44625c0514d2196025301dc91df0 to your computer and use it in GitHub Desktop.
local open = false
local ESX = nil
-- ESX
-- Added this so you can include the rest of the Usage-stuff found on the GitHub page
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
-- Open ID card
RegisterNetEvent('jsfour-idcard:open')
AddEventHandler('jsfour-idcard:open', function( data, type )
open = true
SendNUIMessage({
action = "open",
array = data,
type = type
})
end)
-- Key events
Citizen.CreateThread(function()
while true do
Wait(0)
if IsControlJustReleased(0, 322) and open or IsControlJustReleased(0, 177) and open then
SendNUIMessage({ action = "close" })
open = false
end
if IsControlJustReleased(0, 212) then
openMenu()
open = true
end
end
end)
function openMenu()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'id_card_menu',
{
title = 'ID menu',
elements = {
{label = 'Check your ID', value = 'checkID'},
{label = 'Show your ID', value = 'showID'},
{label = 'Check your driver license', value = 'checkDriver'},
{label = 'Show your driver license', value = 'showDriver'},
{label = 'Check your firearms license', value = 'checkFirearms'},
{label = 'Show your firearms license', value = 'showFirearms'},
}
},
function(data, menu)
local val = data.current.value
if val == 'checkID' then
SendNUIMessage({ action = "close" })
open = false
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
elseif val == 'checkDriver' then
SendNUIMessage({ action = "close" })
open = false
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')
elseif val == 'checkFirearms' then
SendNUIMessage({ action = "close" })
open = false
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'weapon')
else
local player, distance = ESX.Game.GetClosestPlayer()
if distance ~= -1 and distance <= 3.0 then
if val == 'showID' then
SendNUIMessage({ action = "close" })
open = false
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
elseif val == 'showDriver' then
SendNUIMessage({ action = "close" })
open = false
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
elseif val == 'showFirearms' then
SendNUIMessage({ action = "close" })
open = false
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'weapon')
end
else
ESX.ShowNotification('No players nearby')
end
end
end,
function(data, menu)
menu.close()
end
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment