Ok so I am attempting to create a response system for police/ems or whatever job.
but the issue im coming into is that its not notifying all Police or EMS.
ā/ Client
RegisterNetEvent('esx_Policejob:Notify')
AddEventHandler('esx_Policejob:Notify',function(pos, response)
--if PlayerData.job.name == 'police' then
ESX.ShowAdvancedNotification('LSPD INFORMATION', 'CENTRAL LSPD', 'Incoming Call : ' .. response ..' \n~g~Y~s~ To Accept Call \n~r~X~s~ To Refuse.', 'CHAR_CHAT_CALL', 8)
print('Client Side Police Command Used: '.. pos ..' with '.. response)
Citizen.CreateThread(function()
local blipA = AddBlipForRadius(pos.x, pos.y, pos.z, 50.0)
SetBlipHighDetail(blipA, true)
SetBlipColour(blipA, 1)
SetBlipAlpha (blipA, 128)
local blipB = AddBlipForCoord(pos.x, pos.y, pos.z)
SetBlipSprite (blipB, 458)
SetBlipDisplay (blipB, 4)
SetBlipScale (blipB, 1.0)
SetBlipColour (blipB, 1)
SetBlipAsShortRange (blipB, true)
SetBlipHighDetail (blipB, true)
BeginTextCommandSetBlipName ("STRING")
AddTextComponentString (response)
EndTextCommandSetBlipName (blipB)
local timer = GetGameTimer()
while GetGameTimer() - timer < 30000 do
if IsControlJustPressed(1, 246) and GetLastInputMethod(0) then
SetNewWaypoint(pos.x,pos.y)
elseif IsControlJustPressed(1, 73) and GetLastInputMethod(0) then
ESX.ShowNotification('~w~Call Rejected')
end
Citizen.Wait(0)
end
RemoveBlip(blipA)
RemoveBlip(blipB)
end)
--end
end)
ā/Server
RegisterServerEvent('esx_Policejob:Notify:Pass')
AddEventHandler('esx_Policejob:Notify:Pass', function(coords, msg)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local name = xPlayer.getName(source)
local xPlayers = ESX.GetPlayers()
for i = 1, #xPlayers, 1 do
local pPlayer = ESX.GetPlayerFromId(xPlayers[i])
if pPlayer.job.name == 'police' then
TriggerClientEvent('esx_Policejob:Notify', coords, msg)
end
end
print('Server Side Police Command Used: '.. coords ..' with '.. msg)
end)
when i do my test command to trigger the events from client it triggers the server event but does not return the trigger back to the client and when i use the client to client command it registers but only to the player with that job who used the command not to all with the job. i want it to register with all same jobs