TadMad Posted May 20, 2019 Share Posted May 20, 2019 (edited) I need help because I can't figure out how to get the physical parts (doors, panels) of a vehicle that got damaged, I tried using onClientVehicleDamage, but didn't work. I'd like to do a function that restores the door or panel to it's old state when you damage it. (I mean, if the door was damaged when you hit it, it's still damaged, but if it was intact, it keeps intact). I want to disable damaging vehicle parts with fists but keeping the old part state. Edited May 20, 2019 by TadMad Link to comment
Scripting Moderators ds1-e Posted May 20, 2019 Scripting Moderators Share Posted May 20, 2019 (edited) 7 minutes ago, TadMad said: I need help because I can't figure out how to get the physical parts (doors, panels) of a vehicle that got damaged, I tried using onClientVehicleDamage, but didn't work. I'd like to do a function that restores the door or panel to it's old state when you damage it. (I mean, if the door was damaged when you hit it, it's still damaged, but if it was intact, it keeps intact). Check this. https://wiki.multitheftauto.com/wiki/OnClientVehicleCollision + https://wiki.multitheftauto.com/wiki/SetVehiclePanelState Edited May 20, 2019 by majqq Link to comment
TadMad Posted May 20, 2019 Author Share Posted May 20, 2019 8 minutes ago, majqq said: Check this. https://wiki.multitheftauto.com/wiki/OnClientVehicleCollision + https://wiki.multitheftauto.com/wiki/SetVehiclePanelState That only triggers when you collide with the vehicle not when you hit it, and I still can't get the old state. Link to comment
JustinMTA Posted May 21, 2019 Share Posted May 21, 2019 (edited) I can help you. If you add me on Discord or Skype or Telegram, I can do it for you, I'll even do screen share if you wanna watch how I do it. How the broken vehicle parts work is, the game makes the non damaged component invisible, and makes a damaged version visible instead.If you wanna check which parts get damaged, just check the visibility of the broken parts. But if I'm correct, you're asking for a car that can't be visibly damaged while still receiving damage, which I can build into the .DFF of the vehicle, so what I'm saying's, no script's required for what you're asking for. Discord: Slim#0977 Skype: [email protected] Telegram: @JustinX5 Edited May 21, 2019 by JustinMTA Link to comment
savour Posted May 21, 2019 Share Posted May 21, 2019 if you want the vehicle to be immune against fist-punches, try this: addEventHandler("onClientVehicleDamage", root, function(attacker, weapon) if weapon == 0 then cancelEvent() end end ) Link to comment
TadMad Posted May 25, 2019 Author Share Posted May 25, 2019 (edited) On 21/05/2019 at 18:25, savour said: if you want the vehicle to be immune against fist-punches, try this: addEventHandler("onClientVehicleDamage", root, function(attacker, weapon) if weapon == 0 then cancelEvent() end end ) No, that doesn't work. What I mean is that I want to get the physical parts that got damaged and which was it's old state when the player hit the vehicle. Edited May 25, 2019 by TadMad Link to comment
Captain Cody Posted May 27, 2019 Share Posted May 27, 2019 (edited) Sorry for a bit of a late response, haven't been reading forums much lately. https://wiki.multitheftauto.com/wiki/OnClientVehicleDamage https://wiki.multitheftauto.com/wiki/GetVehiclePanelState https://wiki.multitheftauto.com/wiki/SetVehiclePanelState When you active the function loop through the panels and save their states. On vehicle damage loop through and restore their states to what has been saved. damageTable = {} function setVehiclePanelsDamageProof(player) local veh = getPedOccupiedVehicle(player) if isElement(veh) then if damageTable[veh] then damageTable[veh] = nil else damageTable[veh] = {} for i = 0,6 do local state = getVehiclePanelState(veh,i) damageTable[veh][i] = state end end end end addCommandHandler ( "damageProof", setVehiclePanelsDamageProof ) -- # Change this to whatever you want function onVehicleDamage() if isElement(source) and damageTable[source] then for i = 0,6 do setVehiclePanelState(source,i,damageTable[source][i]) end end end addEventHandler("onVehicleDamage", root, onVehicleDamage) Basic script, should work (Untested) . You'll have to modify it to your needs though. When you use the command "damageProof" it loops through the vehicles panels and saves their states (Or if table exists nils it) which enables or disables it. If a table exists (It's enabled) onVehicleDamage it loops through and resets the vehicles panel states. If disabled then it'll ignore it. Edited May 27, 2019 by CodyJ(L) 1 Link to comment
TadMad Posted May 29, 2019 Author Share Posted May 29, 2019 On 27/05/2019 at 18:23, CodyJ(L) said: Sorry for a bit of a late response, haven't been reading forums much lately. https://wiki.multitheftauto.com/wiki/OnClientVehicleDamage https://wiki.multitheftauto.com/wiki/GetVehiclePanelState https://wiki.multitheftauto.com/wiki/SetVehiclePanelState When you active the function loop through the panels and save their states. On vehicle damage loop through and restore their states to what has been saved. damageTable = {} function setVehiclePanelsDamageProof(player) local veh = getPedOccupiedVehicle(player) if isElement(veh) then if damageTable[veh] then damageTable[veh] = nil else damageTable[veh] = {} for i = 0,6 do local state = getVehiclePanelState(veh,i) damageTable[veh][i] = state end end end end addCommandHandler ( "damageProof", setVehiclePanelsDamageProof ) -- # Change this to whatever you want function onVehicleDamage() if isElement(source) and damageTable[source] then for i = 0,6 do setVehiclePanelState(source,i,damageTable[source][i]) end end end addEventHandler("onVehicleDamage", root, onVehicleDamage) Basic script, should work (Untested) . You'll have to modify it to your needs though. When you use the command "damageProof" it loops through the vehicles panels and saves their states (Or if table exists nils it) which enables or disables it. If a table exists (It's enabled) onVehicleDamage it loops through and resets the vehicles panel states. If disabled then it'll ignore it. Thank you for helping 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