Einheit-101 Posted April 16, 2011 Share Posted April 16, 2011 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 Link to comment
Castillo Posted April 16, 2011 Share Posted April 16, 2011 I don't know why, but damage done by MG's, Rockets, is not working, i tryied using onVehicleDamage as a test, and it won't output the health loss, but if i crash him with another vehicle, he do lose health. Link to comment
Einheit-101 Posted April 16, 2011 Author Share Posted April 16, 2011 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
Wojak Posted April 16, 2011 Share Posted April 16, 2011 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
Castillo Posted April 16, 2011 Share Posted April 16, 2011 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
Einheit-101 Posted April 16, 2011 Author Share Posted April 16, 2011 Hmm yes but a Hunter/seasparrow/Rustler MG is not able to damage the Rhino and that is what i want to do^^ There is no function at the moment that retrieves an "hitElement" for "onVehicleFire" because its still in development^^ Link to comment
Arran Posted April 17, 2011 Share Posted April 17, 2011 You can use this custom event: https://wiki.multitheftauto.com/wiki/OnVehicleWeaponFire Then to detect if its targeting a rhino you could use for example: https://wiki.multitheftauto.com/wiki/GetCameraMatrix This is a very hacky way but the best I can think of and also would only work if they happen to be looking right at whatever they're shooting. 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