Emergency location message

Requested here: Officer down script!

/13 make this pop up:

Feel free to edit it how you see fit.

Client script

RegisterCommand('13', function(source, args, rawCommand)
    local ped = PlayerPedId()
    local x,y,z = table.unpack(GetEntityCoords(ped, false))
    local streetName, crossing = GetStreetNameAtCoord(x, y, z)
    streetName = GetStreetNameFromHashKey(streetName)
    local message = ""
    if crossing ~= nil then
        crossing = GetStreetNameFromHashKey(crossing)
        message = "^1" .. GetPlayerName(source) .. " has called a 10-13 near ^3" .. streetName .. " ^1and ^3" .. crossing .. " ^1all units break and roll code 3."
    else
        message = "^1" .. GetPlayerName(source) .. " has called a 10-13 near ^3" .. streetName .. " ^1all units break and roll code 3."
    end
    TriggerServerEvent('sendChatMessage', message)
end, false)

Server script

RegisterServerEvent('sendChatMessage')
AddEventHandler('sendChatMessage', function(message)
    TriggerClientEvent('chatMessage', -1, '', {255,255,255}, message)
end)

On button press

If you rather have this bound to the F6 key, use the following in your client.lua instead:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if IsControlJustReleased(0, 167) then
            local ped = PlayerPedId()
            local x,y,z = table.unpack(GetEntityCoords(ped, false))
            local streetName, crossing = GetStreetNameAtCoord(x, y, z)
            streetName = GetStreetNameFromHashKey(streetName)
            local message = ""
            if crossing ~= nil then
                crossing = GetStreetNameFromHashKey(crossing)
                message = "^1" .. GetPlayerName(PlayerId()) .. " has called a 10-13 near ^3" .. streetName .. " ^1and ^3" .. crossing .. " ^1all units break and roll code 3."
            else
                message = "^1" .. GetPlayerName(PlayerId()) .. " has called a 10-13 near ^3" .. streetName .. " ^1all units break and roll code 3."
            end
            TriggerServerEvent('sendChatMessage', message)
        end
    end
end)

Download in case you have trouble copying the code above

Download contains 3 folders, ā€˜elm-bothā€™, ā€˜elm-button-pressā€™, ā€˜elm-commandā€™, each containing the version suggested by the name. Only install one of them obviously.
Emergency Location Message.zip (4.6 KB)

9 Likes

Does not seem to work on my esx framework:S nice release though

Works on a fresh server installation, not my problem if your ā€œbaseā€ isnā€™t compatible because it uses a crap chat modification.

Simple fix though for all of you using custom crap chat resources, just modify this scriptā€™s RegisterCommand functions to work with the chatMessage events.

4 Likes

Vespura why do you act like a dick to everyone?

6 Likes

Iā€™m not being a dick when saying that this works fine if people didnā€™t use broken resourcesā€¦ thatā€™s just the truth, regardless of the fact if you like the answer or donā€™t.

11 Likes

I have a suggestion can you make it so only police peds can use the command like outlawalerts

Could you make it steam ID based and only people with the steamID can use it? Also are you able to add an ā€œAcceptā€ Function where an officer can accept the backup call which will set a waypoint to them?

This was only meant to be a very simple example, you can modify it yourself however you like.

Read above.

Added an F6 button version that replaces the command. Check it out at the bottom of the OP, up to you which version you use (or use both).

You did everything I asked for, thank you so much. Much love brother

1 Like

I copyed the code and pasted them into the correct files but it still donā€™t work so I tried to make a ā€œ__resource.luaā€ and pasted the contents below:

resource_manifest_version ā€˜77731fab-63ca-442c-a67b-abc70f28dfa5ā€™

client_script ā€˜client.luaā€™
client_script ā€˜server.luaā€™

How do I fix this?

Iā€™ve added a download link to the OP, try that one instead if you are having trouble copying the code.

I am the Owner of Police Department RP. I am using this edit for my server. I modified the script so you can restrict it to only certain police models. I am using this as a panic button for Emergency Services. I figure this should help make sure Civilians arent calling fake emergency messages. I also have it set the 10 code to 10-99 for my server because that is ā€œ10-99 ā€“ Officer in Distress Extreme Emergencyā€ for our server. You can change it to how you please but I figured it would make it better and I figured to share it with you. I also Made it so the persons name highlights blue in color. I gave the client Script Below for you to modify. @Vespura I figure you can change this and use it as you please. I just like to help FiveM as a community. Great Job creating this @Vespura. Thank you!!! ā€“ Bobblemend15 ā€“

This is for the F6 Button Press Only

Client script

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if IsControlJustReleased(0, 167) then -- Set to the "F6" Key
            local PedModels = {
        "s_m_y_cop_01",
        's_m_m_snowcop_01',
        's_m_y_hwaycop_01',
        's_f_y_cop_01',
        's_m_y_sheriff_01',
        's_f_y_sheriff_01',
        's_m_y_ranger_01',
        's_m_m_armoured_01',
        's_m_m_armoured_02',
        's_f_y_ranger_01',
        's_m_m_ciasec_01',
        'u_m_m_fibarchitect',
        's_m_y_swat_01',
		's_m_y_blackops_01',
		's_m_y_blackops_02',
		's_m_y_blackops_03',
		's_m_y_hwaycop_01',
		'u_m_m_doa_01',
		'ig_karen_daniels',
		'cs_karen_daniels'
		}
			local x,y,z = table.unpack(GetEntityCoords(ped, false))
            local streetName, crossing = GetStreetNameAtCoord(x, y, z)
            streetName = GetStreetNameFromHashKey(streetName)
            local message = ""
            if crossing ~= nil then
                crossing = GetStreetNameFromHashKey(crossing)
                message = "^4" .. GetPlayerName(PlayerId()) .. "^1 has called a 10-99 near ^3" .. streetName .. " ^1and ^3" .. crossing .. " ^1all units break and roll code 3."
            else
                message = "^4" .. GetPlayerName(PlayerId()) .. "^1 has called a 10-99 near ^3" .. streetName .. " ^1all units break and roll code 3."
            end
            TriggerServerEvent('sendChatMessage', message)
        end
    end
end)

so this script works? @Daveyentim1

Donā€™t work, just tried

Is there anyway to make this whitelisted? Like add a steam:1100000ā€¦ ?

client

RegisterCommand('13', function(source, args, rawCommand)
               local PedModels = {
        "s_m_y_cop_01",
        's_m_m_snowcop_01',
        's_m_y_hwaycop_01',
        's_f_y_cop_01',
        's_m_y_sheriff_01',
        's_f_y_sheriff_01',
        's_m_y_ranger_01',
        's_m_m_armoured_01',
        's_m_m_armoured_02',
        's_f_y_ranger_01',
        's_m_m_ciasec_01',
        'u_m_m_fibarchitect',
        's_m_y_swat_01',
		's_m_y_blackops_01',
		's_m_y_blackops_02',
		's_m_y_blackops_03',
		's_m_y_hwaycop_01',
		'u_m_m_doa_01',
		'ig_karen_daniels',
		'cs_karen_daniels'
		}
    local x,y,z = table.unpack(GetEntityCoords(ped, false))
	local plyPos = GetEntityCoords(GetPlayerPed(-1),  true)
	local streetName, crossing = Citizen.InvokeNative( 0x2EB41072B4C1E4C0, plyPos.x, plyPos.y, plyPos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
    local streetName, crossing = GetStreetNameAtCoord(x, y, z)
    streetName = GetStreetNameFromHashKey(streetName)
	origin = true
    local message = ""
    if crossing ~= nil then
        crossing = GetStreetNameFromHashKey(crossing)
        message = "^1" .. GetPlayerName(source) .. " has called a 10-13 near ^3" .. streetName .. " ^1and ^3" .. crossing .. " ^1all units break and roll code 3."
    else
        message = "^1" .. GetPlayerName(source) .. " has called a 10-13 near ^3" .. streetName .. " ^1all units break and roll code 3."
    end
    TriggerServerEvent('sendChatMessage', message)
	TriggerServerEvent('gunshotInProgressPos', plyPos.x, plyPos.y, plyPos.z)
	origin = false
end, false)

RegisterNetEvent('gunshotPlace')
AddEventHandler('gunshotPlace', function(gx, gy, gz)
    for i = 0, #PedModels do
        if not origin and IsPedModel(GetPlayerPed(-1),GetHashKey(PedModels[i])) then
            local transG = 250
            local gunshotBlip = AddBlipForCoord(gx, gy, gz)
            SetBlipSprite(gunshotBlip,  433)
            SetBlipColour(gunshotBlip,  1)
            SetBlipAlpha(gunshotBlip,  transG)
            SetBlipAsShortRange(gunshotBlip,  1)
            while transG ~= 0 do
                Wait(blipGunTime * 10)
                transG = transG - 1
                SetBlipAlpha(gunshotBlip,  transG)
                if transG == 0 then
                    SetBlipSprite(gunshotBlip,  2)
                return end
            end
        end
    end
end)

server

RegisterServerEvent('sendChatMessage')
AddEventHandler('sendChatMessage', function(message)
    TriggerClientEvent('chatMessage', -1, '', {255,255,255}, message)
end)

RegisterServerEvent('gunshotInProgressPos')
AddEventHandler('gunshotInProgressPos', function(gx, gy, gz)
	TriggerClientEvent('gunshotPlace', -1, gx, gy, gz)
end)

I tried doing this code with blip but not working :confused: plz help

Have had this Script in my server 4 days now no issues at all and love it! Easy to use and setup!

Nice Works on my Server!

dose not seem to function