#RooTs Posted February 1, 2016 Posted February 1, 2016 Is there a way to cancel vehicle blowing up? onClientVehicleExplode -- or onVehicleExplode and cancelEvent()
#RooTs Posted February 1, 2016 Posted February 1, 2016 client.lua addEventHandler("onClientVehicleExplode", getRootElement(), function() cancelEvent() end) or server.lua addEventHandler("onVehicleExplode", getRootElement(), function() cancelEvent() end) other example addEventHandler ( "onClientVehicleExplode", getRootElement(), cancelEvent ) -- predefined variable "cancelEvent"
ViRuZGamiing Posted February 1, 2016 Posted February 1, 2016 client.lua addEventHandler("onClientVehicleExplode", getRootElement(), function() cancelEvent() end) or server.lua addEventHandler("onVehicleExplode", getRootElement(), function() cancelEvent() end) other example addEventHandler ( "onClientVehicleExplode", getRootElement(), cancelEvent ) -- predefined variable "cancelEvent" [b]Note:[/b] Remember, this event can not be canceled.
#RooTs Posted February 1, 2016 Posted February 1, 2016 [b]Note:[/b] Remember, this event can not be canceled. no ?. how to explain my friends have used this event?
#RooTs Posted February 1, 2016 Posted February 1, 2016 maybe this ? addEventHandler("onVehicleExplode", getRootElement(), function() local theVehicle = getPedOccupiedVehicle(thePlayer) setVehicleDamageProof(theVehicle, true) end)
AMARANT Posted February 1, 2016 Author Posted February 1, 2016 I need to disable blowing up when a vehicle is lying on the roof and starts to burn.
Bonus Posted February 2, 2016 Posted February 2, 2016 Try this: addEventHandler ( "onClientVehicleDamage", root, function ( ) -- If you want it to take damage, but not explode -- -- if getElementHealth ( source ) < 300 then -- dunno if 300 is good, test it local rx,ry = getElementRotation ( source ) if rx > 90 and rx < 270 or ry > 90 and ry < 270 then cancelEvent() -- If it was burning before -- if getElementHealth ( source ) < 300 then setElementHealth ( source, 300 ) -- dunno if 300 is good, test it end end --end end ) I think onClientVehicleDamage should be triggered when the vehicle gets damage when its on the roof.
tosfera Posted February 2, 2016 Posted February 2, 2016 respawn the vehicle with all the data since you cant avoid rockets etc..
Bonus Posted February 2, 2016 Posted February 2, 2016 You can't avoid rockets with onClientVehicleDamage? If you want others to do still damage you can ask if there is an attacker or weapon.
AMARANT Posted February 15, 2016 Author Posted February 15, 2016 respawn the vehicle with all the data since you cant avoid rockets etc.. What do you mean? Just respawn the vehicle?
Captain Cody Posted February 15, 2016 Posted February 15, 2016 onClientVehicleDamage fixVehicle ( vehicleValue ) As soon as it gets damaged use fixVehicle, it will stop it from blowing up and what not.
tosfera Posted February 15, 2016 Posted February 15, 2016 respawn the vehicle with all the data since you cant avoid rockets etc.. What do you mean? Just respawn the vehicle? simple; onVehicleExplode, use a setTimer to avoid your new vehicle from being blown up right away, then use getElementModel, getVehicleColors, getAllElementData and getElementPosition from the old vehicle, set the onto the new one and tada. As if the explosion never happened.
AMARANT Posted February 15, 2016 Author Posted February 15, 2016 simple; onVehicleExplode, use a setTimer to avoid your new vehicle from being blown up right away, then use getElementModel, getVehicleColors, getAllElementData and getElementPosition from the old vehicle, set the onto the new one and tada. As if the explosion never happened. I will try it, thank you for your response!
AMARANT Posted February 16, 2016 Author Posted February 16, 2016 I can spawn a vehicle after blowing up at the right coordinates and make it damage proof. But before that the vehicle needs to be blow up anyway. And I'd like to completely remove blowing up. Is this possible? Here is my code what I've got: function onVehiclesExplode() local model = getElementModel(source) local x, y, z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) destroyElement(source) setTimer(spawnAfterExplode,50,1,model,x,y,z,rx,ry,rz) end addEventHandler("onVehicleExplode", getRootElement(), onVehiclesExplode) function spawnAfterExplode(model,x,y,z,rx,ry,rz) local newvehicle = createVehicle(model,x,y,z,rx,ry,rz) setVehicleDamageProof(newvehicle,true) end
Captain Cody Posted February 16, 2016 Posted February 16, 2016 onClientVehicleDamage fixVehicle ( vehicleValue ) As soon as it gets damaged use fixVehicle, it will stop it from blowing up and what not. --- This --- When missiles hit vehicle the vehicle does not explode that instant, instead there is a small delay, if you use fix vehicle as soon as the vehicle gets damaged, then the vehicle won't go boom.
tosfera Posted February 16, 2016 Posted February 16, 2016 onClientVehicleDamage fixVehicle ( vehicleValue ) As soon as it gets damaged use fixVehicle, it will stop it from blowing up and what not. --- This --- When missiles hit vehicle the vehicle does not explode that instant, instead there is a small delay, if you use fix vehicle as soon as the vehicle gets damaged, then the vehicle won't go boom. If you're not running an RP server, sure. If it's a RP script, good luck saving all the panel states, door states, wheel states, current damage and set it all back when someone hits the vehicle with their fists, an AK or something like that. Even by saying that, in an RPG server players are most likely going to ram each other, f*ck up their friends with guns and sh*t. You're going to use fixVehicle every single bullet? That's going to be insanely CPU killing. I can spawn a vehicle after blowing up at the right coordinates and make it damage proof. But before that the vehicle needs to be blow up anyway. And I'd like to completely remove blowing up. Is this possible? Here is my code what I've got: function onVehiclesExplode() local model = getElementModel(source) local x, y, z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) destroyElement(source) setTimer(spawnAfterExplode,50,1,model,x,y,z,rx,ry,rz) end addEventHandler("onVehicleExplode", getRootElement(), onVehiclesExplode) function spawnAfterExplode(model,x,y,z,rx,ry,rz) local newvehicle = createVehicle(model,x,y,z,rx,ry,rz) setVehicleDamageProof(newvehicle,true) end It should be removed by destroyElement. Maybe add a timer for that one too, or first set the dimension to something random, and delete it after 1 second.
Captain Cody Posted February 16, 2016 Posted February 16, 2016 Oh yes, forgot about that "posted both of those at 1 am wasn't exactly thinking about that atm, when the vehicle health drops below a certain point, use repair vehicle, as to prevent it from exploding, yet still allowing it to be hit, rammed etc without repairing every time.
tosfera Posted February 16, 2016 Posted February 16, 2016 Oh yes, forgot about that "posted both of those at 1 am wasn't exactly thinking about that atm, when the vehicle health drops below a certain point, use repair vehicle, as to prevent it from exploding, yet still allowing it to be hit, rammed etc without repairing every time. As an easier thing; just make the vehicle damage proof when the health drops below 400.
Captain Cody Posted February 16, 2016 Posted February 16, 2016 Well that certainly works to, I really need to stop commenting at 1-7 am
AMARANT Posted February 16, 2016 Author Posted February 16, 2016 Oh yes, forgot about that "posted both of those at 1 am wasn't exactly thinking about that atm, when the vehicle health drops below a certain point, use repair vehicle, as to prevent it from exploding, yet still allowing it to be hit, rammed etc without repairing every time. As an easier thing; just make the vehicle damage proof when the health drops below 400. Yes it really works but how about server CPU if I use it server-side with "onVehicleDamage"?
Captain Cody Posted February 16, 2016 Posted February 16, 2016 If you do the function correctly it won't hurt CPU, onVehicleDamage, then have the function receive current health, if it is below 400 then continue else end.
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