Skip to content
This repository was archived by the owner on Feb 15, 2022. It is now read-only.

Better ESX Panic Button

William Plunkett Jr edited this page Nov 3, 2018 · 2 revisions

Doing this Better ESX Panic Button is a better option. All changes will be made in the esx_policejob script.

Step 1

Put this in the -- Keys Section in client/main.lua

		if IsControlJustPressed(0, Keys['F3']) and GetLastInputMethod(2) and PlayerData.job ~= nil and PlayerData.job.name == 'police' then
			SendPoliceDistressSignal()
		end

For Example to look like this

-- Key Controls
Citizen.CreateThread(function()
	while true do

		Citizen.Wait(10)

		if CurrentAction ~= nil then
			ESX.ShowHelpNotification(CurrentActionMsg)

			if IsControlJustReleased(0, Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'police' then

				if CurrentAction == 'menu_cloakroom' then
					OpenCloakroomMenu()
				elseif CurrentAction == 'menu_armory' then
					if Config.MaxInService == -1 then
						OpenArmoryMenu(CurrentActionData.station)
					elseif playerInService then
						OpenArmoryMenu(CurrentActionData.station)
					else
						ESX.ShowNotification(_U('service_not'))
					end
				elseif CurrentAction == 'menu_vehicle_spawner' then
					OpenVehicleSpawnerMenu(CurrentActionData.station, CurrentActionData.partNum)
				elseif CurrentAction == 'delete_vehicle' then
					if Config.EnableSocietyOwnedVehicles then
						local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
						TriggerServerEvent('esx_society:putVehicleInGarage', 'police', vehicleProps)
					end
					ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
				elseif CurrentAction == 'menu_boss_actions' then
					ESX.UI.Menu.CloseAll()
					TriggerEvent('esx_society:openBossMenu', 'police', function(data, menu)
						menu.close()
						CurrentAction     = 'menu_boss_actions'
						CurrentActionMsg  = _U('open_bossmenu')
						CurrentActionData = {}
					end, { wash = false }) -- disable washing money
				elseif CurrentAction == 'remove_entity' then
					DeleteEntity(CurrentActionData.entity)
				end
				
				CurrentAction = nil
			end
		end -- CurrentAction end
		
		if IsControlJustReleased(0, Keys['PAGEDOWN']) and not isDead and PlayerData.job ~= nil and PlayerData.job.name == 'police' and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'police_actions') then
			if Config.MaxInService == -1 then
				OpenPoliceActionsMenu()
			elseif playerInService then
				OpenPoliceActionsMenu()
			else
				ESX.ShowNotification(_U('service_not'))
			end
		end
		
		if IsControlJustReleased(0, Keys['E']) and CurrentTask.Busy then
			ESX.ShowNotification(_U('impound_canceled'))
			ESX.ClearTimeout(CurrentTask.Task)
			ClearPedTasks(PlayerPedId())
			
			CurrentTask.Busy = false
		end
		
		if IsControlJustPressed(0, Keys['F3']) and GetLastInputMethod(2) and PlayerData.job ~= nil and PlayerData.job.name == 'police' then
			SendPoliceDistressSignal()
		end
	end
end)

Step 2

Add this Function anywhere in client/main.lua

function SendPoliceDistressSignal()
	local playerPed = GetPlayerPed(-1)
	local coords	= GetEntityCoords(playerPed)

	ESX.ShowNotification(_U('distress_sent'))
	TriggerServerEvent('esx_phone:send', 'police', _U('police_distress_message'), false, {
		x = coords.x,
		y = coords.y,
		z = coords.z
	})
end

Step 3

Add this to your locales/en.lua

  ['distress_sent'] = 'distress signal has been sent to available units!',
  ['police_distress_message'] = 'police attention required: OFFICER IN NEED OF ASSISTANCE!',
Clone this wiki locally