[Release] jsfour-idcard [ESX]

any way to make this an item

WORKING CODE FOR THOSE WHO NEEDED HELP OPENING A MENU W/ ID CARDS
Make this your ‘client.lua’

local open = false
local ESX = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj 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)
        -- Controls found in the FiveM docs:
        -- https://docs.fivem.net/game-references/controls/
        if IsControlJustReleased(0, 243) then --` Key
            -- (Taken from the Usage-guide on the GitHub page)
            -- OpenIDMenu
            openMenu()
        end
        if IsControlJustReleased(0, 322) and open or IsControlJustReleased(0, 177) and open then
            SendNUIMessage({
                action = "close"
            })
            open = false
        end
    end
end)

-- A menu (THIS IS AN EXAMPLE)
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)
		if data.current.value == 'checkFirearms' then
			TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'weapon')
		elseif data.current.value == 'showFirearms' then
			 if distance ~= -1 and distance <= 3.0 then
        TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'weapon')
      else
        ESX.ShowNotification('No players nearby')
      end
		elseif data.current.value == 'checkID' then
			TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
    elseif data.current.value == 'showID' then
      local player, distance = ESX.Game.GetClosestPlayer()

      if distance ~= -1 and distance <= 3.0 then
        TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
      else
        ESX.ShowNotification('No players nearby')
      end
    elseif data.current.value == 'checkDriver' then
      TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')
    elseif data.current.value == 'showDriver' then
      local player, distance = ESX.Game.GetClosestPlayer()

      if distance ~= -1 and distance <= 3.0 then
        TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
      else
        ESX.ShowNotification('No players nearby')
      end
		end
	end,
	function(data, menu)
		menu.close()
	end
)
end
1 Like

Hi,

the ID cards cannot be viewed, can someone help me? I have already edited the client.lua.

what’s the error you are getting in your console ?

this works for 1.2 ?
without essentialmode?

I am using both , but if I turn off essentialmode it doesn’t work

Hi, thanks for the answer. There is no error in the console. The menu works fine, I just can’t look at the ID cards or show them to someone else.

you need to have either a register command or controlled key to function viewing or showing someone your ID … thishttps://forum.cfx.re/t/release-jsfour-idcard-esx/169787/363?u=romntc would help you have a menu to do what you are looking for … just change line 23

there isn’t anything in this link

Compatible with vrpex?