Jump to content

[HELP] Detect vehicle physical parts damaged


TadMad

Recommended Posts

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 by TadMad
Link to comment
  • Scripting Moderators
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 by majqq
Link to comment

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 by JustinMTA
Link to comment
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 by TadMad
Link to comment

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 by CodyJ(L)
  • Like 1
Link to comment
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 :D

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...