Xwad Posted March 13, 2015 Share Posted March 13, 2015 Hi. How can I make a script that allows me to repair a vehicle with a chain saw when I hit the vehicle? Link to comment
Emilio_M Posted March 13, 2015 Share Posted March 13, 2015 https://wiki.multitheftauto.com/wiki/On ... WeaponFire https://wiki.multitheftauto.com/wiki/GetElementType https://wiki.multitheftauto.com/wiki/FixVehicle Link to comment
Mega9 Posted March 13, 2015 Share Posted March 13, 2015 @Emilio_M that event is not triggered by melee weapons. Use https://wiki.multitheftauto.com/wiki/On ... icleDamage instead. Link to comment
Xwad Posted March 13, 2015 Author Share Posted March 13, 2015 That is what i made i think its not good:/ Can you help me a little bit to correct the failures? local weaponsToDamageVehicle = { [9] = true } function handleVehicleDamage(attacker, weapon, loss, x, y, z, tyre) if (attackerweapon == 41) and (loss > 1) and ( theHealth < 95 ) then setVehicleHealth ( source, theHealth+17 ) fixVehicle ( vehicleValue ) end addEventHandler("onClientVehicleDamage", root, handleVehicleDamage) Link to comment
xeon17 Posted March 13, 2015 Share Posted March 13, 2015 1. theHealth isn't defined 2. vehicleValue isn't defined , use source instead which is the vehicle which get damaged. 3. There isn't a function called setVehicleHealth , i guess you mean setElementHealth but there isn't need for this function, fixVehicle will work. Link to comment
Xwad Posted March 13, 2015 Author Share Posted March 13, 2015 ok its working now thanks. Link to comment
Xwad Posted March 13, 2015 Author Share Posted March 13, 2015 one more question. Is this server side? function healFlowers (attacker, attackerweapon, bodypart, loss) theHealth = getElementHealth (source) if ( theHealth > 95 ) then --checks clients health end else if (attackerweapon == 41) and (loss > 1) and ( theHealth < 95 ) then setElementHealth ( source, theHealth+17 ) givePlayerMoney (attacker, 1.7*theHealth) end end end addEventHandler ("onPlayerDamage", getRootElement(), healFlowers ) Link to comment
Xwad Posted March 13, 2015 Author Share Posted March 13, 2015 this script allows to heal players when i hit with spraycan. but not working:/ Link to comment
xeon17 Posted March 13, 2015 Share Posted March 13, 2015 function healFlowers (attacker, attackerweapon, bodypart, loss) theHealth = getElementHealth (source) if ( theHealth > 95 ) then return end if (attackerweapon == 41) and (loss > 1) and ( theHealth < 95 ) then setElementHealth ( source, theHealth+17 ) givePlayerMoney (attacker, 1.7*theHealth) end end addEventHandler ("onPlayerDamage", getRootElement(), healFlowers ) 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