class World
package fivem.client.core
Queries against the world as this client sees it.
Everything here is limited to what is streamed in. A client only has
entities within a few hundred metres of the player, so allVehicles()
means "vehicles I can currently see", never "vehicles on the server". For
server-wide queries, ask the server.
var nearest = World.closestVehicle(LocalPlayer.coords(), 20.0);
if (nearest != null) nearest.repair();Static methods
staticclosestPed(position:Vector3, radius:Float = 10.0, includePlayers:Bool = false):Ped
The nearest ped to position within radius, or null.
Scans the streamed-in ped pool rather than calling GET_CLOSEST_PED,
whose output parameter isn't reachable through the generated externs,
and which can't exclude the player asking.
staticclosestVehicle(position:Vector3, radius:Float = 10.0, ?model:Hash, flags:Int = 70):Vehicle
The nearest vehicle to position within radius, or null.
Parameters:
model | Restrict to one model, or leave |
|---|---|
flags | The game's search flags; 70 (the default) finds ordinary drivable vehicles including wrecks. |
staticinlinedistance(from:Vector3, to:Vector3, useZ:Bool = true):Float
Straight-line distance between two points.
staticentitiesInRadius(position:Vector3, radius:Float, poolName:String = "CPed"):Array<Entity>
Every entity of the given pool within radius of position, nearest first.
staticgroundZ(position:Vector3, includeWater:Bool = false):Null<Float>
The ground height under position, or null when the collision there
isn't streamed in.
Always check for null before using the result as a spawn height — a
0 fallback puts things at sea level, usually under the map.
staticpool(poolName:String):Array<Int>
Raw handles from one of the game's entity pools: "CPed",
"CVehicle", "CObject" or "CPickup".
staticsnapToGround(position:Vector3, includeWater:Bool = false):Vector3
position snapped down onto the ground, or unchanged when the ground
height can't be determined.