esx_fireDispatch-Discontiniued icon indicating copy to clipboard operation
esx_fireDispatch-Discontiniued copied to clipboard

Request for triggering a random fire by having firefighters online

Open MoravianLion opened this issue 5 years ago • 3 comments

So, I’ve been experimenting with triggering startFire command automatically when Firefighters are online, but ran into this issue

InvokeNative: execution failed: Argument at index 1 was null. SCRIPT ERROR: Execution of native 000000002f7a49e6 in script host failed.

The problem is in the line TriggerClientEvent(‘esx_fireDispatch:startFire’) and I can’t figure out what I did wrong here…

client:

---------------------------- Commands ---------------------------- --[[ RegisterCommand("startFire", function() local i = math.random(#fireSpawnLocation) -- Choses a random spawn location TriggerServerEvent("fireManager:syncFire", i); -- sends sync requests end, false)]]

function startFire() local i = math.random(#fireSpawnLocation) -- Choses a random spawn location TriggerServerEvent("fireManager:syncFire", i) -- sends sync requests end

server

Citizen.CreateThread(function() while true do Citizen.Wait(5000) local xPlayers = ESX.GetPlayers() local firefighters = 0 for i=1, #xPlayers, 1 do local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) if xPlayer.job.name == 'fire' then firefighters = firefighters + 1 end end if(firefighters >= 1)then print("Firefighters are online!") TriggerClientEvent('esx_fireDispatch:startFire') -- without this line, the check works fine else print("Firefighters are off duty!") end end end)

P.S. Sorry for formatting, I don't understand how it work here on GitHub yet.

MoravianLion avatar Oct 12 '19 13:10 MoravianLion

I will also be looking to add this to the script. (Otherwise the server will be constantly spawning fires, when there is no-one to put them out.

Sythy11 avatar Oct 13 '19 00:10 Sythy11

function startFire() local i = math.random(#fireSpawnLocation) -- Choses a random spawn location TriggerServerEvent("fireManager:syncFire", i) -- sends sync requests end

That's just not how it works. I'm not going to answer you as there is a reason it isn't implemented in the script yet, it takes a lot of modifying. But I'll look at adding this feature in the near future.

Pyth3rEx avatar Oct 13 '19 03:10 Pyth3rEx

I'd like to see this added.

nzkfc avatar Jun 14 '21 11:06 nzkfc