Skip to content

← Previous | Next →


getClosestVehicle

Description

Finds the closest vehicle to the NPC within a specified distance, optionally filtered by model and flag, and stores the vehicle entity in a global variable.

Basic information

Name Type Possibilities
getClosestVehicle behaviour 1

Parameters

# Name Type Mandatory Description Multiple
1 vehicle Entity Yes The global variable name where the vehicle entity will be stored. No
2 distance number Yes The maximum distance to search for a vehicle. No
3 model string No The model of the vehicle to filter the search. If not specified, any model is accepted. No
4 flag number No An optional flag to further filter the vehicle search. Defaults to 0 if not specified. No

Outputs

# Description
1 The closest vehicle was found and stored in the global variable.

Example


  NPC 

  name Driver 
  model s_m_y_cop_01 
  position -1020.72 4839.78 258.30 0.0 

  interaction 
    nothing 

  behaviour 
    getClosestVehicle closestVehicle 1000