Jump to content

SWAT vehicle repairing cars on fire


xTravax

Recommended Posts

Hey umm,i wanted to ask,how would i make a script which would repair vehicle on fire while throwing water on it from swat?

if you don't understand what i wanted to say,here's another example:

i got a swat van,i see a player in a vehicle which is on fire,i approach it with my swat van and start throwing water at it,and after 1 second the car gets repaired.

i don't know how to start doing this,mostly whats confusing me is how to check if swat is throwing water on vehicle.

please help

Link to comment
However, as far as I'm aware - there is no way to tell MTA to put out a fire on a car. At least not as of now.

well,in that case,fixVehicle probably would do the thing.

but i don't know how to even detect if swat vehicle is throwing water at car on fire so thats my main problem and i don't know what to do

Link to comment

I found one example at wiki of this..

  
function handleVehicleDamage(attacker, weapon, loss, x, y, z, tyre) 
    if (weapon and getElementModel(source) == 601) then 
        -- A weapon was used and the vehicle model ID is that of the SWAT tank so cancel the damage. 
        cancelEvent() 
    end 
end 
addEventHandler("onClientVehicleDamage", root, handleVehicleDamage) 
  

Link to comment
function vehicleFireFix(weapon, _, _, _, _, _, element) 
  if weapon == 42 and element and getElementType(element) == "vehicle" then 
    local health = getElementHealth(element) 
    if health < 500 then -- dont want to "fix" healthy cars 
      --fixVehicle(element) -- uncomment to fix the damage model also 
      setElementHealth(element, health + 10) 
    end 
  end 
end 
addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), vehicleFireFix) 

© aibo

https://forum.multitheftauto.com/viewtopic.php?f=91&t=30806

What the search button not can do...

Link to comment

I think either you guys are misunderstanding him, or I am.

As it stands, there is no current way of putting out the fire. Yes, you can cancel the event and prevent the player from taking damage - but that doesn't put the fire out.

And of course you can make it so the water actually repairs the vehicles.

Link to comment

That doesnt change the fact, that the event won`t trigger because the hitElement is a vehicle and those events trigger if a Player/Ped was hit, not any other elements. You could attach some invisible PED`s to vehicles, lol^^

You would need something like "onElementHitByWater" and this does not exist.

I tested the code and onClientPlayerWeaponFire doesnt trigger for Swatvan. It does only trigger for the Fire Extinguisher in player`s hand.

Link to comment

of course you could calculate the turret position and maybe the position it is aiming and you could calculate the trajectory of the flying water and maybe calculate if this water would hit any element in its way BUT is anyone able to create such a monster?

It would be easier to add a Event for the water cannon.

Link to comment

As mentioned before, attaching a ped would work.

I wrote a very, very basic example. You can download it here. This isn't meant for actual use, and only a proof-of-concept and how you could do it. It's not perfect since the ped is in the center of the vehicle, triggering the event via hitting the rear will prove difficult.

Also, I didn't test it on bigger vehicles.

To Use;

1. Start the resource and type /create.

2. This will create a vehicle with a ped attached to it.

3. Shoot it with your water cannon, and the vehicle's alpha will change. Using the event "onVehicleHitByWaterCannon" server-side. This returns 2 elements, the vehicle that shot the cannon - and the vehicle that got hit.

I also added code for it to attach peds to a vehicle whenever a player enters one - and store it in a table. You can use this server-side table to kill peds at will.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...