Jump to content

question about setElementVelocity


matito6

Recommended Posts

Posted

Hey.

I do not know how to do the "setElementVelocity" was speeding to the front of the "0.30". Please help can there another way to speed up? Please help :)

Posted

Use:

function getElementSpeed ( element , unit ) 
    if not element or not isElement ( element ) then 
        return false 
    end 
    if unit == "kph" then 
        unit = 1.61 
    else 
        unit = 1 
    end 
    local velX , velY , velZ = getElementVelocity ( element ) 
    return ( velX ^ 2 + velY ^ 2 + velZ ^ 2 ) ^ 0.5 * unit * 100 
end 
     
function setElementSpeed ( element , unit , speed ) 
    if not element or not isElement ( element ) then 
        return false 
    end 
    if not speed then 
        speed = 0 
    end 
    local acSpeed = getElementSpeed ( element , unit ) 
    local diff = speed / acSpeed 
    local velX , velY , velZ = getElementVelocity ( element ) 
    setElementVelocity ( element , velX * diff , velY * diff , velZ * diff ) 
    return true 
end 

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted

These functions can be used to get/set a element speed, not just vehicles.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
addCommandHandler("speed", 
function (thePlayer, cmd, theSpeed) 
    local theSpeed = tonumber(theSpeed) 
    local vehicle = getPedOccupiedVehicle(thePlayer) 
    if (theSpeed and vehicle) 
        setElementSpeed(vehicle, "kph", theSpeed) 
    end 
end) 
  
function getElementSpeed ( element , unit ) 
    if not element or not isElement ( element ) then 
        return false 
    end 
    if unit == "kph" then 
        unit = 1.61 
    else 
        unit = 1 
    end 
    local velX , velY , velZ = getElementVelocity ( element ) 
    return ( velX ^ 2 + velY ^ 2 + velZ ^ 2 ) ^ 0.5 * unit * 100 
end 
    
function setElementSpeed ( element, unit , speed ) 
    if not element or not isElement ( element ) then 
        return false 
    end 
    if not speed then 
        speed = 0 
    end 
    local acSpeed = getElementSpeed ( element , unit ) 
    local diff = speed / acSpeed 
    local velX , velY , velZ = getElementVelocity ( element ) 
    setElementVelocity ( element , velX * diff , velY * diff , velZ * diff ) 
    return true 
end 

That should add a command: /speed .

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

it does not work. I would like to, if you type "/ speed Euro" I got the speed right away

such that the car accelerated (DM maps) It can be done?

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