[HELP] EMS cant send Distress Signal by Button Press [Ambulance]

Continuing the discussion from [HELP] EMS cant found player who died:

Hi folks, I would like to ask if anyone knows, if there is a dead Person they can’t send a distress signal?
Im searching for some time and well i didnt really found anything.

Exactly about esx_ambulancejob a slightly old version ‘1.2.0’.
Thanks in advance.

-- Disable most inputs when dead
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)

		if IsDead then
			DisableAllControlActions(0)
			EnableControlAction(0, 47, true)
			EnableControlAction(0, 245, true)
			EnableControlAction(0, 38, true)
		else
			Citizen.Wait(500)
		end
	end
end)

function OnPlayerDeath()

--if GetPlayerRoutingBucket(source) ~= 5 then
	IsDead = true
	local second = 1000

	Citizen.CreateThread(function()
		repeat
			Citizen.Wait(300 * second)
			ClearPedTasksImmediately(GetPlayerPed(-1))
		until IsDead == false
	end)
		
	ESX.UI.Menu.CloseAll()
	TriggerServerEvent('esx_ambulancejob:setDeathStatus', true)

	StartDeathTimer()
	--SendDistressSignal()

	ClearPedTasksImmediately(GetPlayerPed(-1))
	StartScreenEffect('DeathFailOut', 0, false)
--end
end

function StartDistressSignal()
	Citizen.CreateThread(function()
		local timer = Config.EarlyRespawnTimer

		while timer > 0 and IsDead do
				Citizen.Wait(2)
				timer = timer - 30

			SetTextFont(4)
			SetTextScale(0.0, 0.5)
			SetTextColour(255, 255, 255, 255)
			SetTextDropshadow(0, 0, 0, 0, 255)
			SetTextEdge(1, 0, 0, 0, 255)
			SetTextDropShadow()
			SetTextOutline()
			SetTextCentre(true)
			BeginTextCommandDisplayText('STRING')
			AddTextComponentSubstringPlayerName(_U('distress_send'))
			EndTextCommandDisplayText(0.175, 0.805)

			if IsControlPressed(1, Keys['E']) then
				SendDistressSignal()
				
				Citizen.CreateThread(function()
					Citizen.Wait(60000)
					if IsDead then
						StartDistressSignal()
					end
				end)

				break
			end
		end
	end)
end

function SendDistressSignal()
	local playerPed = PlayerPedId()
	local coords    = GetEntityCoords(playerPed)
	local position = {x = coords.x, y = coords.y, z = coords.z}


	TriggerEvent("d-phone:client:message:senddispatch", "Verletzte Person entdeckt!", "ambulance", 0, 1, position, "5")
	TriggerEvent("d-notification", "Dein Notruf wurde abgesetzt", 5000,  "rgba(255, 0, 0, 0.8)")
end

function DrawGenericTextThisFrame()
	SetTextFont(4)
	SetTextScale(0.0, 0.5)
	SetTextColour(255, 255, 255, 255)
	SetTextDropshadow(0, 0, 0, 0, 255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	SetTextOutline()
	SetTextCentre(true)
end

I would try using the /panic command and put that into your server. ex/ whenever a First Responder is down you do /panic and the whole server gets the noti but Police officers can respond to it

thx for the response, it is a nice work around ^^ but i really want to send a dispatch via d-phone when you are down you Press a button and then the ambulance recive it

I havent seen anything like that

On German RP server it’s Standart. When your dead you send a signal to a phone than an first responder will see and drives from an Hospital or firestation to position and Revives the Person

I mean, it’s just an “SMS” message, right? Find whatever hook d-phone has for adding messages and route it through the “SendDistressSignal()” function (or something else, that’s up to you of course lol) so it sends the message.

Yea, sending and the hook to the phone is not the Problem. I can’t get to this point. My “ERROR” apperas earlier, i cant get the Button to Work. When your dead, you cant Push any Button. but it isn’t restricted.

It is restricted. This block of code, specifically:

		if IsDead then
			DisableAllControlActions(0)
			EnableControlAction(0, 47, true)
			EnableControlAction(0, 245, true)
			EnableControlAction(0, 38, true)
		else
			Citizen.Wait(500)
		end

Be sure that the buttons you’re trying to use are actually enabled as DisableAllControlActions(0) disables all controls.

mh, yea i see but isn’t it that when i block all first and enable some specified keys after it would work? so i mean the hole keyboard is disabled but only these keys are enabled? So thats my thinking about this.

You mean i should rather restrict alle the keys i don’t want and the keys i want not even mentioning?