[Free] VehicleBurn - Starts engine fire when on roof!

image

What does it do exactly?

This is a super small resource that will damage (and ultimately explode) vehicles that are on their
roof similar to e.g. GTA San Andreas. It can also prevent the manual rollover function.
It kind of makes people feel safe and then: BOOM! … Classic :smiley:

Showcase video:

Download

Requirements

  • OneSync

Features

  • Vehicle starts taking engine damage when on roof.
  • Configurable damage per second.
  • Configurable if vehicle should explode at full engine damage.
  • Disable manual rollover of a vehicle.

Performance

  • Client Side: 0.00ms
  • Server Side: 0.00ms-0.02ms (depends on the amount of vehicles present on the server)

Installation instructions

  1. Extract the downloaded folder into your resources.
  2. Start the resource in your server.cfg:
    ensure VehicleBurn
    

Support

If you want to further support my work, consider taking a look at my Tebex store. Maybe you can find something you would like :slight_smile:

8 Likes

very nice esx?

This is standalone. It will work on every framework or none at all. Literally doesn’t matter.

The only scripts that might be incompatible are other vehicle damage scripts.

very nice brother

2 Likes

just a suggestion, but doing a loop server sided will not be the best to do for something like this. Reason being, every two seconds, your server will be gathering this information for every vehicle ‘known’ within the server. So say if you have 30 people in vehicles, every 2 seconds server will be gathering the vehicle information, seeing if the damage is necessary to start the engine to burn and then execute that.

I would suggest just making this a client script but i do believe their is a function already that detects if the engine is at a certain health, it can explode. if you want to keep it how you have it, thats fine but the suggestion would be to make it a client sided script vs a server tick as it will essentially not be the best thing for the server to have a continous loop. Having anything in a createthread loop on server side is just not optimal and should ‘try’ to avoid doing so.

Below is not tested but should give you somewhat of a result that could be ‘fun’. otherwise i just laid out a structure for people to mess with if they want to do more with it.

– SetDisableVehicleEngineFires(vehicle, toggle) – i never used this function, but you might be able to just put this into a loop that checks every second [Citizen.Wait(1)]

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(5000) -- can be lowered
		local ply = PlayerPedId()
		local veh = IsPedInAnyVehicle(ply, false) -- checks if in vehicle
		local driver = GetPedInVehicleSeat(ply, -1) -- checks if they are the driver

		if veh then 
			if driver then
				print('[have this to test what engine health you would want it to start fire / explode]', GetVehicleEngineHealth(veh))
				if GetVehicleEngineHealth(veh) < 10 then -- change value if you want
					ExplodeVehicle(veh, true, true) -- this will explode once the vehicle is 10 health or less while driver is in it
				end
			end
		end
end)

If you are looking to keep this a server sided script, i would look into SetTimeout()'s as that is generally what most restart scripts that tick every X amount of seconds use and might be a bit more optimal for this.

function loopVehBurn()
	SetTimeout(2000, function()
		--INSERT LOOP MINUS THE CITIZEN.CREATETHREAD AND THE WAIT()
	end)
end

loopVehBurn()
1 Like

I understand your concerns on doing this but it actually ensures that the damage is distributed correctly.

My main problem here is that I would have to check everything for every single client. Which kind of leads to the same result, just with every clients performance instead of just the server. I generally try to squeeze every bit of performance for the clients. (coming from someone with 150+fps anyways xD)

Also doing it on server side allows triggering it on the client that can actually set values on the vehicle (the network owner).

E.g. you flip your vehicle and then start checking client side and applying damage. Then the player exits the vehicle. Now at some point the network owner can change and thus your client cannot deal damage anymore.

Now in theory I could just trigger a server event from that point and do it like I do after detecting the vehicles been flipped on server side, but why just go through all that if I can do it on server side in the first place.
This way you can even get in a bulldozer and flip a vehicle without someone inside and it will catch on fire.

Now one thing I actually thought about just now would be using state bags instead of triggering an event. But I am unsure if that would put more or less stress on the networking side (triggering an event on one client versus sending the health value to all clients in scope of the entity).

Another performance improvement would be to “stretch” checking the vehicles over those 2 seconds instead of doing them all at once. E.g. at 100 vehicles just check 25, wait 0.5 seconds, check the next 25 etc.

I also feel like 0.02ms on server side for around 100-200 vehicles (the amount we tested this on) is fine. Of course bigger servers might say something else but that remains to be seen.

For now I think this resource is in a “good enough” state for what it actually is.
But thanks for the ideas! I’ll definitely come back to it once we get more server side natives for this kind of stuff, so we can take the client completely out of the equation :smiley: