getRandomVehicleInSphere
GET_RANDOM_VEHICLE_IN_SPHERE0x386F6CE5BAF6091CThe GTA V native GET_RANDOM_VEHICLE_IN_SPHERE of the VEHICLE namespace, as LS:MP client scripts call it: the global function getRandomVehicleInSphere, in JavaScript and in Lua.
getRandomVehicleInSphere(
x: number,
y: number,
z: number,
radius: number,
modelHash: Hash,
flags: number
): VehiclegetRandomVehicleInSphere(
x: number,
y: number,
z: number,
radius: number,
modelHash: Hash,
flags: integer
): VehicleUsage
JavaScript
const vehicle = getRandomVehicleInSphere(x, y, z, radius, modelHash, flags);Lua
local vehicle = getRandomVehicleInSphere(x, y, z, radius, modelHash, flags)Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.
JavaScript · with vectors
const vehicle = getRandomVehicleInSphere(pos, radius, modelHash, flags);Lua · with vectors
local vehicle = getRandomVehicleInSphere(pos, radius, modelHash, flags)Parameters
| Parameter | Type | JavaScript | Lua | Description |
|---|---|---|---|---|
x | float | number | number | The X-component of the position of the sphere. |
y | float | number | number | The Y-component of the position of the sphere. |
z | float | number | number | The Z-component of the position of the sphere. |
radius | float | number | number | The radius of the sphere. Max is 9999.9004. |
modelHash | Hash | number | integer | The vehicle model to limit the selection to. Pass 0 for any model. |
flags | int | number | integer | The bitwise flags that modifies the behaviour of this function. |
Returns
Vehicle JavaScript number, Lua integerGame handle of a vehicle. Not an LS:MP netId. Convert one with lsmp.getEntityFromNetId.
Notes
From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.
Gets a random vehicle in a sphere at the specified position, of the specified radius.
Full list of vehicles by DurtyFree: https://github.com/DurtyFree/gta-v-data-dumps/blob/master/vehicles.json
Reference
- Namespace
- Vehicle VEHICLE
- In the game
Vehicle GET_RANDOM_VEHICLE_IN_SPHERE(float x, float y, float z, float radius, Hash modelHash, int flags)- Hash
0x386F6CE5BAF6091C