> ## Documentation Index
> Fetch the complete documentation index at: https://docs.markz3d.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FindSafe

Finds the nearest safe, optionally filtered by distance and model. Only enabled safes are searched.

<table>
  <thead>
    <tr>
      <th scope="col">
        Argument
      </th>

      <th scope="col">
        Data Type
      </th>

      <th scope="col">
        Needed
      </th>

      <th scope="col">
        Default
      </th>

      <th scope="col">
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <th>`coords`</th>
      <td>vector3</td>
      <td>❌</td>
      <td>`nil`</td>
      <td>The coordinates to search from, if `nil` the distance is ignored and a matching safe is returned</td>
    </tr>

    <tr>
      <th>`distance`</th>
      <td>number</td>
      <td>❌</td>
      <td>`nil`</td>
      <td>The maximum distance from `coords`, if `nil` there is no limit</td>
    </tr>

    <tr>
      <th>`model`</th>
      <td>string</td>
      <td>❌</td>
      <td>`nil`</td>
      <td>Only match safes of this model, if `nil` every model is matched</td>
    </tr>
  </tbody>
</table>

> **Returns**
>
> <table>
>   <thead>
>     <tr>
>       <th scope="col">
>         Type
>       </th>
>
>       <th scope="col">
>         Description
>       </th>
>     </tr>
>   </thead>
>
>   <tbody>
>     <tr>
>       <td>string | nil</td>
>
>       <td>
>         The id of the nearest matching safe, or `nil` if none was found
>       </td>
>     </tr>
>   </tbody>
> </table>

> **Example**
>
> ```lua theme={null}
> local safeId = exports["mxc_safe"]:FindSafe(GetEntityCoords(GetPlayerPed(source)), 3.0, "mxc_safe_prop_base_01")
>
> if safeId then
>     print("Found the safe", safeId)
> end
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.