Tails Posted August 25, 2012 Posted August 25, 2012 Hi guys. I am attempting to edit a little part of the Admin script in MTA. What I want is instead of /slap the players health but the players vehicle health. Is there a way to edit the script below so that it does? This is the part of the script: elseif ( action == "slap" ) then if ( getElementHealth ( player ) > 0 ) and ( not isPedDead ( player ) ) then if ( ( not data ) or ( not tonumber ( data ) ) ) then data = 20 end if ( ( tonumber ( data ) >= 0 ) ) then if ( tonumber ( data ) > getElementHealth ( player ) ) then setTimer ( killPed, 50, 1, player ) else setElementHealth ( player, getElementHealth ( player ) - data ) end local x, y, z = getElementVelocity ( player ) setElementVelocity ( player, x , y, z + 0.2 ) mdata = data else action = nil end Thanks in advance!
Castillo Posted August 25, 2012 Posted August 25, 2012 You can check if the target is on a vehicle with: isPedOnVehicle, and if he/she is, then get his/her vehicle with: getPedOccupiedVehicle.
Tails Posted August 25, 2012 Author Posted August 25, 2012 I'm sorry I am still a complete noob. How would I add that into that complicated script?
Castillo Posted August 25, 2012 Posted August 25, 2012 elseif ( action == "slap" ) then local vehicle = getPedOccupiedVehicle ( player ) local theElement = ( vehicle and vehicle or player ) if ( getElementHealth ( theElement ) > 0 ) then if ( getElementType ( theElement ) == "player" and not isPedDead ( theElement ) ) or ( getElementType ( theElement ) == "vehicle" and not isVehicleBlown ( theElement ) ) then if ( ( not data ) or ( not tonumber ( data ) ) ) then data = 20 end if ( ( tonumber ( data ) >= 0 ) ) then if ( tonumber ( data ) > getElementHealth ( theElement ) ) then if ( getElementType ( theElement ) == "player" ) then setTimer ( killPed, 50, 1, theElement ) else setTimer ( blowVehicle, 50, 1, theElement ) end else setElementHealth ( theElement, getElementHealth ( theElement ) - data ) end local x, y, z = getElementVelocity ( theElement ) setElementVelocity ( theElement, x , y, z + 0.2 ) mdata = data else action = nil end else action = nil end else action = nil end
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