xTravax Posted March 17, 2014 Share Posted March 17, 2014 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
Dealman Posted March 18, 2014 Share Posted March 18, 2014 I know how to detect if a car is one fire since I have disabled vehicles in my gamemode from taking damage from it. 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. Link to comment
xTravax Posted March 18, 2014 Author Share Posted March 18, 2014 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
Einheit-101 Posted March 18, 2014 Share Posted March 18, 2014 Absolutely not possible. Cleo may be able to do this but not MTA. Too many vehicle functions / events are missing. Link to comment
Anubhav Posted March 18, 2014 Share Posted March 18, 2014 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
denny199 Posted March 18, 2014 Share Posted March 18, 2014 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
Dealman Posted March 18, 2014 Share Posted March 18, 2014 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
Einheit-101 Posted March 18, 2014 Share Posted March 18, 2014 Does OnClientPlayerWeaponFire even trigger if swatvan fires his water cannon and does it return any hit element? Link to comment
cheez3d Posted March 18, 2014 Share Posted March 18, 2014 https://wiki.multitheftauto.com/wiki/On ... aterCannon https://wiki.multitheftauto.com/wiki/On ... aterCannon Maybe this is triggered when the water reaches the player inside a vehicle? Then you can get the player's vehicle and do your stuff. Link to comment
Einheit-101 Posted March 18, 2014 Share Posted March 18, 2014 it returns a player element, not a vehicle. it shouldn't even trigger for a vehicle. I think it is not possible... as i mentioned before. Link to comment
cheez3d Posted March 18, 2014 Share Posted March 18, 2014 You can use getPedOccupiedVehicle(). Link to comment
Einheit-101 Posted March 18, 2014 Share Posted March 18, 2014 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
Moderators IIYAMA Posted March 19, 2014 Moderators Share Posted March 19, 2014 Indeed, Einheit-101. But there a lot of ways to do it. https://wiki.multitheftauto.com/wiki/Ge ... enPosition https://wiki.multitheftauto.com/wiki/ProcessLineOfSight https://wiki.multitheftauto.com/wiki/GetBoundKeys getPedOccupiedVehicle setElementHealth getElementHealth Event: "onClientRender" Etc. People there is a lot possible with mta... Link to comment
Einheit-101 Posted March 19, 2014 Share Posted March 19, 2014 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
Dealman Posted March 19, 2014 Share Posted March 19, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now