- Documentation
- Shared functions
- getPointFromDistanceRotation
Function
getPointFromDistanceRotation
Returns a point at the given distance from (x, y) in the given direction. Angles as in GTA: 0 is north and they grow counter-clockwise.
Syntax
float, float getPointFromDistanceRotation(float x, float y, float distance, float angle)Arguments
xfloat- X position.
yfloat- Y position.
distancefloat- Distance.
anglefloat- Direction in degrees.
Returns
The new X and Y or false.
Example
Places a vehicle 5 metres in front of the player.
addCommandHandler("auto", function(player)
local x, y, z = getElementPosition(player)
local _, _, rz = getElementRotation(player)
local vx, vy = getPointFromDistanceRotation(x, y, 5, rz)
createVehicle(411, vx, vy, z, 0, 0, rz)
end)