Jump to content

Making damage with Hunter MG to Rhino


Recommended Posts

Hello Community!

I want to write a script that improves the damage system of the rhino (more fragile, making damage with heavy MG`s and so on) but now i dont know how to make damage to the rhino if a Hunter`s machine gun hits the tank because there is no useful function onVehicleWeaponFire that returns a hitElement.

So I want to retrieve when a Hunter is Firing his MG and if this MG hits the Rhino, it should loose 5 health points

like that: setElementHealth(getElementHealth()-5)

So is there anything i can do to damage a rhino with MG`s?

I hope for an Answer :D

Link to comment

Of course. A rhino CAN NOT BE DAMAGED with any weapon except Flamethrowers or Molotovs (Fire.) and you can only damage a rhino with that 2 weapons or if you drive it against a wall. shoot 99999 bullets of a minigun on a rhino. he still has 1001 HP.

Link to comment

i only know how to do it with rockets:

you maus use the onClientExplosion event, and check if the explosion is near rihno, than you damage the tank by getElementHealth,setElementHealth (helth functions should be used serverside, so you will ned some custom events as well)

https://wiki.multitheftauto.com/wiki/OnClientExplosion

https://wiki.multitheftauto.com/wiki/GetElementHealth

https://wiki.multitheftauto.com/wiki/SetElementHealth

Link to comment

I've done this script for you, this set's the rhino health when you hit it with a weapon (ex: M4), grenades, rockets won't work as i can see.

--server side

addEvent("setTheTankHealth",true) 
addEventHandler("setTheTankHealth",getRootElement(), 
function(tank) 
setElementHealth(tank, getElementHealth(tank) - 5) 
end 
) 

--client side

addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), 
function (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
    if (hitElement) then 
    if getElementType(hitElement) == "vehicle" then 
    if getElementModel(hitElement) == 432 then 
    triggerServerEvent("setTheTankHealth",getLocalPlayer(),hitElement) 
    end 
     end 
   end 
end) 

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