[Release] jsfour-idcard [ESX]

show id esx.rar (1.3 MB)

To add the other id cards you need to add them to the menu.

 `-- Look at your own driver license
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')

-- Show your driver license to the closest person
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


-- Look at your own firearms license
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'weapon')

-- Show your firearms license to the closest person
local player, distance = ESX.Game.GetClosestPlayer()

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

well it does not matter actually but the thing is i want to make it so that you press F2 which is open inventory button and there u could show your id card or something like that. Is that example code for the esx menu? or?

Thereā€™s a ESX menu on the GitHub yes. The other code snippets can pretty much be used where ever you want

yes i know but the thing is when i put the idcard files to resources folder and add the start idcard to server.cfg then i do not know which button to press to look at my idcard etc or do i need to add something more to something

Yeah you need to add a button by yourself

aaah alright well maybe i do not use this script then cuz i canā€™t add a button to esx menu :smiley: thanks anyways

i know i push a lotā€¦ anybody can share a client.lua with me that as already a working menu in itā€¦
then ill start from there. please.
happy new year

It has nothing to do with ESX. Itā€™s a fivem native https://runtime.fivem.net/doc/natives/#_0xF3A21BCD95725A4A

i tried to use personmeny for this id card, and now i can see my id card but it does not show my licenses

if you used the one i posted above you will need to add the others to the list

1 Like

yeah trying to figure out on where to add the other ones and what code exactly, and yes i have used the one you posted above. I canā€™t seem to figure out how do i add those other cards

can you post screeshot on your file if you added them so i could see exactly where to put that code thanks :slight_smile: trying to learn this so badly

1 Like
function OpenShowGiveID()

ESX.UI.Menu.Open(
	'default', GetCurrentResourceName(), 'id_card_menu',
	{
		title    = _U('id_menu'),
		elements = {
			{label = _U('check_id'), value = 'check'},
			{label = _U('show_id'), value = 'show'}
		}
	},
	function(data2, menu2)
		if data2.current.value == 'check' then
			TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
		elseif data2.current.value == 'show' then
			local player, distance = ESX.Game.GetClosestPlayer()

			if distance ~= -1 and distance <= 3.0 then
				TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
				OpenTrashCan()
			else
				OpenAttansCan()
				ESX.ShowNotification(_U('nobody_near'))
			end
		end
	end,
	function(data2, menu2)
		menu2.close()
		OpenCivilianActionsMenu()
	end
)

end

nice thanks so i was modifying the right file but didnā€™t seem to get it to work, need to tamper with it some more

This is one with all the jsfour id cards in it.
Im not running esx anymore so i could test if i missed a comma anywhere so just let me knowā€¦

jsfour id menu-all ids.rar (5.6 MB)

4 Likes

hi jsfour, thank you for your sharing of scripts, I would like to know how to add the head of our character on the ID card, I try this:
client side:
SetEntityAsMissionEntity (GetPlayerPed (-1))
local PED_ID = NetworkGetNetworkIdFromEntity (GetPlayerPed (-1))
TriggerServerEvent (ā€˜jsfour-idcard: openā€™, playerTarget, PED_ID)
server side:
RegisterNetEvent (ā€œjsfour-idcard: openā€)
AddEventHandler (ā€œjsfour-idcard: openā€, function (PED_ID)
local handle = RegisterPedheadshot (PED_ID)
while not IsPedheadshotReady (handle) do
Wait (100)
end
local headshot = GetPedheadshotTxdString (handle)
while true do
Wait (20)
DrawSprite (headshot, headshot, 0.40, 0.4, 0.09, 0.18, 0.0, 255, 255, 255, 1000)
end
end)
possible ?

im getting an error:

Error running system event handling function for resource jsfour-idcard: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: server.lua:8: attempt to index a nil value (upvalue 'ESX')
stack traceback:
        server.lua:8: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:219: in function <citizen:/scripting/lua/scheduler.lua:218>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:218: in function <citizen:/scripting/lua/scheduler.lua:182>

i just made a clean install

How do i use the menu from your code?

-- 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)
		local val = data.current.value
		
		if val == 'checkID' then
			TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
		elseif val == 'checkDriver' then
			TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')
		elseif val == 'checkFirearms' then
			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
				TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
				elseif val == 'showDriver' then
			TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
				elseif val == 'showFirearms' then
			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
1 Like

Would probably be possible if you position the sprite correctly

Looks like you donā€™t have ESX installed