ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setElementVelocity

Function

setElementVelocity

Server and clientElementsIdentical to MTA:SA

Sets the element's velocity (1 is 50 m/s). On the client it works for your own character and vehicle; on the ground the ped's animation cancels horizontal movement, vertical always works.

Syntax

bool setElementVelocity(element theElement, float speedX, float speedY, float speedZ)

Arguments

theElementelement
The element.
speedXfloat
X speed.
speedYfloat
Y speed.
speedZfloat
Z speed.

Returns

true on success.

Example

bindKey("lshift", "down", function()
    local veh = getPedOccupiedVehicle(localPlayer)
    if veh then
        local vx, vy, vz = getElementVelocity(veh)
        setElementVelocity(veh, vx * 1.5, vy * 1.5, vz)
    end
end)

See also