[HELP] Ambulance Job Dispatch Blip

Hey guys i have a question i use esx legacy and i want to add a blip to the ambulancejob on the map that comes when you press G (47). Have there taken a template but unfortunately that does not work quite have you there ne idea what I did wrong?

Client Side

function getEMSNotified()

local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.job.name == 'ambulance' then
    local blips = {
         {title= "Attention required" , colour=3, id=1, x = PedPosition.x, y = PedPosition.y, z = PedPosition.z }
    }

    --[[Citizen.CreateThread(function()
        for _, info in pairs(blips) do
          info.blip = AddBlipForCoord(info.x, info.y, info.z)
          SetBlipSprite(info.blip, info.id)
          SetBlipDisplay(info.blip, 4)
          SetBlipScale(info.blip, 1.0)
          SetBlipColour(info.blip, info.colour)
          SetBlipAsShortRange(info.blip, true)
          BeginTextCommandSetBlipName("STRING")
          AddTextComponentString(info.title)
          EndTextCommandSetBlipName(info.blip)
        end
    end)]]
    TriggerServerEvent("esx_ambulancejob:helpblip", blips)
    TriggerEvent("chatMessage", "DISPATCH ", 3, 'a medic should be informed by now, you can still use /me')

end
end

RegisterNetEvent(‘esx_ambulancejob:sendhelpblip’)
AddEventHandler(‘esx_ambulancejob:sendhelpblip’, function(blips)

Citizen.CreateThread(function()
        for _, info in pairs(blips) do
          info.blip = AddBlipForCoord(info.x, info.y, info.z)
          SetBlipSprite(info.blip, info.id)
          SetBlipDisplay(info.blip, 4)
          SetBlipScale(info.blip, 1.0)
          SetBlipColour(info.blip, info.colour)
          SetBlipAsShortRange(info.blip, true)
          BeginTextCommandSetBlipName("STRING")
          AddTextComponentString(info.title)
          EndTextCommandSetBlipName(info.blip)
        end
    end)

end)

Server Side TOP

ESX = nil

local playersHealing, deadPlayers = {}, {}

TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)

TriggerEvent(‘esx_phone:registerNumber’, ‘ambulance’, _U(‘alert_ambulance’), true, true)

TriggerEvent(‘esx_society:registerSociety’, ‘ambulance’, ‘Ambulance’, ‘society_ambulance’, ‘society_ambulance’, ‘society_ambulance’, {type = ‘public’})

ServerSide

RegisterServerEvent(‘esx_ambulancejob:helpblip’)
AddEventHandler(‘esx_ambulancejob:helpblip’, function(blips)

local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local Players = ESX.GetPlayers()

for i=1, #Players, 1 do
TriggerClientEvent(‘esx_ambulancejob:sendhelpblip’, Players[i], blips)
end
end)

I would really appreciate any help

warm greetings

you are not defining ESX on the client side. so your calling ESX.GetPlayerFromId(_source) but ESX isn’t valid, i’m also fairly sure that is a server side function but i don’t use ESX so can’t advise much on that.

Thank you for your answer but have already tried to make the function in serverside without success. for further readers use this [Help] Send blip to online players with ambulance job and a notification - #6 by Fanto66

are you basically trying to make an ambulance panic button type thing? if so then maybe start by looking at the police panic button and going from that.

So I try if one is dead and the Dead fesnter comes where one is asked then whether one should press G around an emergency call to set since I want to use a new cell phone which has however still no dispatch function I would have to make this for the time being so that dead players can be revived a panic button would be then always usable

Ok, first if u use legacy u need to delete ESX = nil and TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end) u just need to go on fxmanifest.lua and put shared_script '@es_extended/imports.lua'
U can’t use xPlayer on client-side too, i will let you a .lua here to show u how u can get job to a client-side
Captura

Jo has worked so far but had to replace the == against ~=.

And then just insert the blip without ESx nil because it should work learn to script it yourself customize and bugfixes are no problem only write your own codes give still problems

Hey greetings you as have now managed to get without an error but I get no blip created has who ne idea why?

CLIENT

function StartDistressSignal()

CreateThread(function()

    local timer = Config.BleedoutTimer

    while timer > 0 and isDead do

        Wait(0)

        timer = timer - 30

        SetTextFont(4)

        SetTextScale(0.45, 0.45)

        SetTextColour(185, 185, 185, 255)

        SetTextDropshadow(0, 0, 0, 0, 255)

        SetTextDropShadow()

        SetTextOutline()

        BeginTextCommandDisplayText('STRING')

        AddTextComponentSubstringPlayerName(_U('distress_send'))

        EndTextCommandDisplayText(0.175, 0.805)

        if IsControlPressed(0, 47) then

            SendDistressSignal()

            getEMSNotified()

            Citizen.CreateThread(function()

                Citizen.Wait(1000 * 60 * 5)

                if IsDead then

                    StartDistressSignal()

                   

                end

            end)

            break

        end

    end

end)

end

function getEMSNotified()

ESX.TriggerServerCallback('esx_ambulancejob:isEMS', function(hasJob)

    if hasJob then

        exports['t-notify']:Alert({

            style = 'error',

            message = 'Example alert from the client side'

        })

        Citizen.CreateThread(function()

            for _, info in pairs(blips) do

              info.blip = AddBlipForCoord(info.x, info.y, info.z)

              SetBlipSprite(info.blip, 161)

              SetBlipDisplay(info.blip, 4)

              SetBlipScale(info.blip, 2.0)

              SetBlipColour(info.blip, 3)

              SetBlipAsShortRange(info.blip, true)

              BeginTextCommandSetBlipName("STRING")

              AddTextComponentString(info.title)

              EndTextCommandSetBlipName(info.blip)

              PulseBlip(blipRobbery)

            end

        end)

    else

        print('No Job')

    end

end)

end

SERVER

ESX.RegisterServerCallback(‘esx_ambulancejob:isEMS’, function(source, cd)

local _source = source

local xPlayer = ESX.GetPlayerFromId(_source)

if xPlayer.job.name ~= 'ambulance' then

    cd(true)

else

    cd(false)

end

end)

RegisterServerEvent(‘esx_ambulancejob:helpblip’)

AddEventHandler(‘esx_ambulancejob:helpblip’, function(blips)

local _source = source

local xPlayer = ESX.GetPlayerFromId(_source)

local Players = ESX.GetPlayers()



for i=1, #Players, 1 do

    TriggerClientEvent('esx_ambulancejob:sendhelpblip', Players[i], blips)

end

end)

Greet thanks!!

1 Like