[Help]Stop/Start fire script

I am trying to make a fire script with a stop fire command and i am trying to figure out how to stop the fire here is what i have so far:
client.lua

RegisterNetEvent("StartFire")
AddEventHandler("StartFire", function()
	local Coords = GetEntityCoords(GetPlayerPed(-1))
	StartScriptFire(Coords.x, Coords.y+3, Coords.z-1, 25, 0)
	StartScriptFire(Coords.x, Coords.y+4, Coords.z-1, 25, 0)
	StartScriptFire(Coords.x, Coords.y+5, Coords.z-1, 25, 0)
end)

RegisterNetEvent("StopFires")
AddEventHandler("StopFires", function()
StopFireInRange(float x, float y, float z, float radius)
end)

server.lua:

AddEventHandler('chatMessage', function(player, playerName, message)
	local message = string.lower(message)
    if message:sub(1) == '/startfire' then
        TriggerClientEvent('StartFire', player)
        CancelEvent()
    end
end)


AddEventHandler('chatMessage', function(player, playerName, message)
	local message = string.lower(message)
    if message:sub(1) == '/stopfires' then
        TriggerClientEvent('StopFires', player)
        CancelEvent()
    end
end)

AddEventHandler('chatMessage', function(player, playerName, message)
	local message = string.lower(message)
    if message:sub(1) == '/stopfires' then
        TriggerClientEvent('StopFires', player)
        CancelEvent()
    end
end)

first of all, wtf are all those chatMessage events? :scream: use RegisterCommand please

1 Like

StartScriptFire should return an int with the handle ID for that fire. Save the handle when you start it, then stop it later using void REMOVE_SCRIPT_FIRE(int fireHandle);

uhh where do i find the RegisterCommand event/function?

https://wiki.fivem.net/wiki/RegisterCommand

1 Like

return an int? like what i don’t have much of the fire script part of knowledge
and for the void fact does it work by just adding in the void part or is there a full code part?

Also how would i add the fire commands using the RegisterCommand

	local fire1 = StartScriptFire(Coords.x, Coords.y+3, Coords.z-1, 25, 0)
	local fire2 = StartScriptFire(Coords.x, Coords.y+4, Coords.z-1, 25, 0)
	local fire3 = StartScriptFire(Coords.x, Coords.y+5, Coords.z-1, 25, 0)

fire1, etc will be the handle for those fires.

so instead of startscriptfire it sould be this:

RegisterNetEvent("StartFire")
AddEventHandler("StartFire", function()
	local Coords = GetEntityCoords(GetPlayerPed(-1))
	local fire1 = StartScriptFire(Coords.x, Coords.y+3, Coords.z-1, 25, 0)
	local fire2 = StartScriptFire(Coords.x, Coords.y+4, Coords.z-1, 25, 0)
	local fire3 = StartScriptFire(Coords.x, Coords.y+5, Coords.z-1, 25, 0)
end)

as client.lua?

would become

    RegisterCommand('startfire', function(source,args,rawcommand) 
   TriggerEvent('StartFire')
    end, false)
2 Likes