[Help] Installing esx-snippet for police job

I’m not the best on lua :=) but can someone help me to install esx-snippet license check/remove to my server?

https://github.com/ESX-PUBLIC/ESX-Snippet/tree/master/police

Did you ever get help with this? Doesn’t seem like anyone ever wants to help.

First thing you are going to want to do is add this to the bottom of your server/main.lua

function ShowPermis(source,identifier)
  local _source = source
  local licenses = MySQL.Sync.fetchAll("SELECT * FROM user_licenses where `owner`= @owner",{['@owner'] = identifier})

    for i=1, #licenses, 1 do

        if(licenses[i].type =="weapon")then
         TriggerClientEvent('esx:showNotification',_source,"Permis de port d'arme")
        end
        if(licenses[i].type =="dmv")then
            TriggerClientEvent('esx:showNotification',_source,"Code de la route")
        end
        if(licenses[i].type =="drive")then
            TriggerClientEvent('esx:showNotification',_source,"Permis de conduire")
        end
        if(licenses[i].type =="drive_bike")then
           TriggerClientEvent('esx:showNotification',_source,"Permis moto")
        end
        if(licenses[i].type =="drive_truck")then
          TriggerClientEvent('esx:showNotification',_source,"Permis camion")
        end


    end

end



RegisterServerEvent('esx_policejob:license_see')
AddEventHandler('esx_policejob:license_see', function(target)

  local sourceXPlayer = ESX.GetPlayerFromId(source)
  local targetXPlayer = ESX.GetPlayerFromId(target)

  local identifier = GetPlayerIdentifiers(target)[1]


  TriggerClientEvent('esx:showNotification', sourceXPlayer.source, '~b~'..targetXPlayer.name)
  ShowPermis(source,identifier)




end)

Then you are going to want to open your client/main.lua and search for the following CTRL+F.

citizen_interaction

Should look something like this


then under the search label you want add the new one

 {label = 'Voir les permis',            value = 'license_see'},

Then scroll down a little till you see the if data


and after the end
add a new line then paste this

if data2.current.value == 'license_see' then
              TriggerServerEvent('esx_policejob:license_see', GetPlayerServerId(player))
          end

Then save and restart it should work

1 Like

Hi. What about to add give licence for police job like:

 function OpenPoliceActionsMenu()
	ESX.UI.Menu.CloseAll()

	ESX.UI.Menu.Open(
	'default', GetCurrentResourceName(), 'police_actions',
	{
		title    = 'Police',
		align    = 'top-left',
		elements = {
			{label = _U('citizen_interaction'),	value = 'citizen_interaction'},
			{label = _U('vehicle_interaction'),	value = 'vehicle_interaction'},
			{label = _U('object_spawner'),		value = 'object_spawner'},
			{label = "Zatvor Meni",               value = 'jail_menu'}, -- You add this line
			{label = _U('license_add'),	value = 'addLicense'}
		}
	},

and

elseif action == 'addLicense' then
						OpenLicenceMenu(closestPlayer)

and then something like:

function OpenLicenceMenu(player)

	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'licence',
	{
		title    = _U('licence'),
		align    = 'top-left',
		elements = {
			{label = _U('gun_licence'), value = 0},
			{label = _U('rifle_licence'),   value = 1}
		}
	}, function(data, menu)
		OpenLicenceCategoryMenu(player, data.current.value)
	end, function(data, menu)
		menu.close()
	end)

end

and


function OpenLicenceCategoryMenu(player, category)

	ESX.TriggerServerCallback('esx_license:addLicense', function(target, type, cb)

I’m really looking for a complete function. Can someone help?