Jump to content

Change vehicles health


Tails

Recommended Posts

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!

Link to comment
        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 

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