class World
package fivem.server.core
Server-side world queries.
Unlike the client's World, this sees everything — the server has no
streaming distance, so allVehicles() really is every vehicle in the
session.
for (vehicle in World.allVehicles()) {
if (vehicle.owner == -1) vehicle.delete(); // orphaned, clean it up
}Static methods
staticclosestVehicle(position:Vector3, radius:Float = 50.0):Vehicle
The closest vehicle to position within radius, or null.
staticdeleteOwnEntities():Void
Removes every entity this resource created that is still lying around.
Worth calling from a resource stop handler: server-created entities outlive their resource, so a restart otherwise leaves the previous run's vehicles and props scattered across the map.
staticentitiesInRadius(position:Vector3, radius:Float, entityType:Int = 1, ?models:Array<Int>):Array<Entity>
Entities of one type within radius of position, nearest first.
Parameters:
entityType | 1 peds, 2 vehicles, 3 objects. |
|---|---|
models | Restrict to these model hashes, or leave |