How i can do that player's get weapon license only from police?

Hello,
is there any way to do layers only can get weapon’s license from police?

Resource that i use:
esx_policejob: GitHub - esx-framework/esx_policejob: FXServer ESX Police Job
esx_weaponshop: GitHub - esx-framework/esx_weaponshop: Legal and illegal weapon shop
esx_license: GitHub - esx-framework/esx_license: FXServer ESX License

4 Likes

You need to modify esx_weaponshop and esx_policejob files.

Follow the instructions below:

Weapon Shop:

esx_weaponshop/client/main.lua > Line 222

Replace

	OpenBuyLicenseMenu(CurrentActionData.zone)

With

	ESX.ShowNotification("You do not have weapon license!")

Police Job

esx_policejob/client/main.lua > 260 - Add

{label = 'Weapon License (take/give)', value = 'weapon_license'}

esx_policejob/client/main.lua > 303 - Add

elseif action == 'weapon_license' then
    TriggerServerEvent('esx_policejob:weaponLicense', GetPlayerServerId(closestPlayer))
end

esx_policejob/server/main.lua > Add anywhere

RegisterNetEvent('esx_policejob:weaponLicense')
AddEventHandler('esx_policejob:weaponLicense', function(target)
	local _source = source

	local xPlayer = ESX.GetPlayerFromId(_source)
	local xTarget = ESX.GetPlayerFromId(target)

	if xPlayer.getJob().name == 'police' then
		TriggerEvent('esx_license:checkLicense', target, 'weapon', function(hasWeaponLicense)
			if hasWeaponLicense then
				TriggerEvent('esx_license:removeLicense', target, 'weapon')
				TriggerClientEvent('esx:showNotification', _source, _U('license_take', xTarget.getName()))
			else
				TriggerEvent('esx_license:addLicense', target, 'weapon')
				TriggerClientEvent('esx:showNotification', _source, _U('license_give', xTarget.getName()))
			end
		end)
	end
end)
8 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.