GetClosestPed
info
Finds the closest pedestrian (NPC or player) within a specified distance from the player's current location.
Use this export in your scripts.
Parameters
maxDistance: The maximum distance within which to search for pedestrians (number).searchType: Type of pedestrian to search for. Use "players" to find players or "npcs" to find NPCs or "both" to find both (string).
Returns
closestPed: The ped it foundclosestDist: The distance to that pedclosestCoords: The coords of the ped
Usage
- Lua
- Javascript
local closestPed, closestDist, closestCoords = exports['FS-Lib']:GetClosestPed(10.0, "players")
const [closestPed, closestDist, closestCoords] = exports['FS-Lib'].GetClosestPed(10.0, "players")