[Release] Advanced 911 - Team see's call, not whole server [1.0]

Use the FiveM to discord bot and add 911 to the commands

Better question, how can I modify this script so /911 displays to only leo/fdpeds but the command doesn’t have to require /fd,pd, ems.

I’ll send my .lua s, Almost got it but im missing something…

Try this @RyanMcCowen

Client

local peds = {
    "ped1",
    "ped2",
}

RegisterNetEvent('Fax:SendCall')
AddEventHandler('Fax:SendCall', function(desc, callid)
    local ped = GetPlayerPed(PlayerId())

	if checkPed(ped, peds) then
		TriggerServerEvent("Fax:SendCallToTeam", desc, callid)
	end
end)

Server

RegisterCommand("911", function(source, args, rawCommand)
    local desc = table.concat(args, " ", 1)
    local s = source

        if desc == nil then
            TriggerClientEvent("chatMessage", source, "^1Please specify a call description.")
        else
            callid = s
            TriggerClientEvent("Fax:SendCall", -1, desc, callid)
            TriggerClientEvent("chatMessage", source, "^4911 Call Sent to.")
        end
end)

RegisterServerEvent("Fax:SendCallToTeam")
AddEventHandler("Fax:SendCallToTeam", function(desc, callid)
    local s = source

    TriggerClientEvent("chatMessage", s, "^4911 Call [ID:" .. callid .. "] " .. desc)
end)

client.lua

-----------------------------------
--- Advanced 911, Made by FAXES ---
-----------------------------------

--- CONFIG ---
--- CONFIG ---
local leoPeds = {
    "s_m_y_cop_01",
	"csb_cop",
	"s_f_y_cop_01",
	"s_f_y_ranger_01",
	"s_f_y_sheriff_01",
	"s_m_m_chemsec_01",
	"s_m_m_ciasec_01",
	"s_m_m_marine_01",
	"s_m_m_marine_02",
	"s_m_m_prisguard_01",
	"s_m_y_pilot_01",
	"s_m_y_ranger_01",
	"s_m_y_sheriff_01",
	"s_m_y_swat_01",
	"s_m_y_uscg_01",
	"s_m_y_hwaycop_01",
}

local fdPeds = {
    "s_m_y_fireman_01",
    "s_m_m_paramedic_01",
}

---------------------------------------------------------------------------------
RegisterNetEvent('Fax:SendCall')
AddEventHandler('Fax:SendCall', function(desc, callid)
    local ped = GetPlayerPed(PlayerId())

		if checkPed(ped, leoPeds) then
			TriggerServerEvent("Fax:SendCallToTeam", desc, callid)
		end
		if checkPed(ped, fdPeds) then
			TriggerServerEvent("Fax:SendCallToTeam", desc, callid)
		end
    end
end)

function checkPed(ped, PedList)
	for i = 1, #PedList do
		if GetHashKey(PedList[i]) == GetEntityModel(ped) then
			return true
		end
	end
	return false
end

server.lua

-----------------------------------
--- Advanced 911, Made by FAXES ---
-----------------------------------

RegisterCommand("911", function(source, args, rawCommand)
    local desc = table.concat(args, " ", 2)
    local s = source
		else
            callid = s
            TriggerClientEvent("Fax:SendCall", s, desc, callid)
            TriggerClientEvent("chatMessage", source, "^4911 Call Sent")
        end

    else
        TriggerClientEvent("chatMessage", source, "^1Incorrect")
    end
end)

RegisterServerEvent("Fax:SendCallToTeam")
AddEventHandler("Fax:SendCallToTeam", function(desc, callid)
end)

will check right now, ignore my post of mine

As I said try what I sent just add your peds and stuff your server definitely won’t work as you have an else without an if statement lol.

did not work, I get the message “Call sent to” and I tried several peds that I put in the “ped1, 2” but the call didnt show

I just tested this and it works fine

Client

local leoPeds = {
	"s_m_y_cop_01",
	"s_m_y_hwaycop_01",
}

local fdPeds = {
    "s_m_y_fireman_01",
    "s_m_m_paramedic_01",
}

---------------------------------------------------------------------------------
RegisterNetEvent('Fax:SendCall')
AddEventHandler('Fax:SendCall', function(desc, callid)
    local ped = GetPlayerPed(PlayerId())

	if checkPed(ped, leoPeds) then
		TriggerServerEvent("Fax:SendCallToTeam", desc, callid)
	end
end)

function checkPed(ped, PedList)
	for i = 1, #PedList do
		if GetHashKey(PedList[i]) == GetEntityModel(ped) then
			return true
		end
	end
	return false
end

Server

local leoPeds = {
	"s_m_y_cop_01",
	"s_m_y_hwaycop_01",
}

local fdPeds = {
    "s_m_y_fireman_01",
    "s_m_m_paramedic_01",
}

---------------------------------------------------------------------------------
RegisterNetEvent('Fax:SendCall')
AddEventHandler('Fax:SendCall', function(desc, callid)
    local ped = GetPlayerPed(PlayerId())

	if checkPed(ped, leoPeds) then
		TriggerServerEvent("Fax:SendCallToTeam", desc, callid)
	end
end)

function checkPed(ped, PedList)
	for i = 1, #PedList do
		if GetHashKey(PedList[i]) == GetEntityModel(ped) then
			return true
		end
	end
	return false
end

you posted the same thing twice :stuck_out_tongue:

the client and server are the same I mean

That makes no sense what so ever. Even a beginner would understand the client and the server have two completely different functions. What happens for you only happens locally. I can almost guarantee it won’t happen for other players the way the script is set up.

Wait oops lmao

Add this to the server pasted the client twice

Server

RegisterCommand("911", function(source, args, rawCommand)
    local desc = table.concat(args, " ", 1)
    local s = source

    if desc == nil then
        TriggerClientEvent("chatMessage", source, "^1Please specify a call description.")
    else
        callid = s
        TriggerClientEvent("Fax:SendCall", -1, desc, callid)
        TriggerClientEvent("chatMessage", source, "^4911 Call Sent to.")
    end
end)

RegisterServerEvent("Fax:SendCallToTeam")
AddEventHandler("Fax:SendCallToTeam", function(desc, callid)
    local s = source

    TriggerClientEvent("chatMessage", s, "^4911 Call [ID:" .. callid .. "] " .. desc)
end)

Awesome, works well, thanks @BabbaTundaee. Now 2 more questions. (1) What’s the best way to set this up for a discord webhook. (2) Is there a way to make it so instead of specific peds being able to see the call, people who have typed /onduty can see it. I look forward to your reply, thanks :slight_smile:

A car would probs be best. @RyanMcCowen give me a couple and I’ll shoot you a CMD you could use.

It depends what you use, I use SQL perms to receive calls, instead of skins.

So following up on the webhook part, suggestions on how to incorporate it?

It depends what exactly do you want it to do?

just have it so any /911 calls appear in their own discord chat. We had one before that someone set up but it was with its own script, 911 call and webhook together. This one is different obviously.