[Release] jsfour-idcard [ESX]

how to config this script?

hi ive try edit this code, add some new field ‘job grade’
my server.lua look

local ESX = nil
-- ESX
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

-- Open ID card
RegisterServerEvent('jsfour-idcard:open')
AddEventHandler('jsfour-idcard:open', function(ID, targetID, type)
	local identifier = ESX.GetPlayerFromId(ID).identifier
	local _source 	 = ESX.GetPlayerFromId(targetID).source

	MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', {['@identifier'] = identifier},
	function (user)
		MySQL.Async.fetchAll('SELECT job_grades.label FROM users INNER JOIN job_grades ON users.job = job_grades.job_name WHERE users.identifier=@identifier && users.job_grade = job_grades.grade', {['@identifier'] = identifier},
		function (grades)
			if (user[1] ~= nil) then
				MySQL.Async.fetchAll('SELECT type FROM user_licenses WHERE owner = @identifier', {['@identifier'] = identifier},
				function (licenses)
					local array = {
						user = user,
						grades = grades,
						licenses = licenses
					}
					TriggerClientEvent('jsfour-idcard:open', _source, array, type)
				end)
			end
		end)
	end)
end)


i have in init.js additional var grade = event.data.array[‘grade’];
and its not working. Some ideas to fix it?

Have you tried to print the table you get from the database?
It returns {"label":"name of grade" }

Which means you can’t access the name of the grade just by doing event.data.array[‘grade’];

Where i add these things ? (Sorry my english is bad)

Run them like every other resource

Can you help me with this code

-- ### Event usages:

-- Look at your own ID-card
TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))

-- Show your ID-card 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))
else
  ESX.ShowNotification('No players nearby')
end


-- 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

-- ### 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

I don’t know where to add this, i’m using esx_personmeny

Hi,
if you want my files for jsfour idcard and nb_menuperso, look my new tuto in YT, i share my files in description. Is for jsfour in the menu.
I’m french sorry for english people but you can dl the files and copy&paste.

3 Likes

Can you somehow upgrade this? Im a mafia member, and i want to sell fake id cards to orher players. Can you make a ring where i can buy fake id card, and then i can write everything. Than finisg te card, than sell it ti someone. So can you make them writeable, and shareable? I would love this if you can :heart_eyes:

2 Likes

How i can make this great script to item file ? i don’t really want menu

you making nice stuff :smiley:

Thanks it finally works for me cool.

How to get the name from job_grades label ?

1 Like

So I got it to work with wk_actionmenu the only thing I can’t seem to get to work is the showid to proximity. which always leads to an error that says Error During NUI Callback @wk_actionmenu/cl_action:56: attempt to index a nil value (upvalue ‘ESX’). Not really sure if you could help but I figured I’d at least ask

Edit I got it to work I was missing the shared object syntax which i completely overlooked

How to use idcard

I couldn’t manage to make the blindfold function. It does nothing am I missing something?

And gun licence shows up even if you don’t have a licence.

YOu need to update to the new ID system were it checks to see if you have the ID first.
The blindfold you can download for JSfours github

I solved the blindfold, I didnt realzed it needs the item.

Can you give a link for the ID system?

Just look at the top post. my aio was done before he pushed the have id check

Thanks for the headsup I did it :slight_smile:


i have license menu

press F5

config
start license_menu

license_menu.zip (2.7 KB)

1 Like